Published On: 1970-01-01|Last Updated: 1970-01-01|Categories: Uncategorized|
Cygwin のトロさが納得いかないので Windows と Linux でプロセス生成にどんだけ差があるのか適当に測定。

Windows XP x64 SP2 @ Phenom II 550BE: 43.6312226426

Ubuntu 10.04 LTS @ Phenom II 550BE: 30.2954580784

Ubuntu は上の xp64 マシン上の vmware 仮想マシン。

import os, tempfile, shutil, timeit
from distutils.ccompiler import new_compiler
if __name__ == '__main__':
tmpdir = tempfile.mkdtemp()
try:
cc = new_compiler()
srcname = os.path.join(tmpdir, __name__ + '.c')
open(srcname, 'w').write("int main(){ return 0; }")
objnames = cc.compile([srcname, ], output_dir=tmpdir)
cc.link_executable(objnames, __name__, output_dir=tmpdir)
exename = os.path.join(tmpdir, cc.executable_filename(__name__))
benchmarker = timeit.Timer(
'subprocess.call(%r)' % exename, 'import subprocess')
print benchmarker.timeit(10000)
finally:
shutil.rmtree(tmpdir)

関連