PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/python/performance/harness.py

#
Python | 30 lines | 22 code | 7 blank | 1 comment | 0 complexity | a3f4342bcaa396fb53b415e684b22d07 MD5 | raw file
 1#!/usr/bin/env
 2
 3import sys
 4import time
 5import imp
 6from subprocess import *
 7
 8def run (proc) :
 9
10    try :
11        mod = imp.find_module(sys.argv[1])
12        mod = imp.load_module(sys.argv[1], *mod)
13
14        t1 = time.clock()
15        proc(mod)
16        t2 = time.clock()
17        print "%s took %f seconds" % (mod.__name__, t2 - t1)
18
19    except IndexError :
20        proc = Popen([sys.executable, 'runme.py', 'Simple_baseline'], stdout=PIPE)
21        (stdout, stderr) = proc.communicate()
22        print stdout
23
24        proc = Popen([sys.executable, 'runme.py', 'Simple_optimized'], stdout=PIPE)
25        (stdout, stderr) = proc.communicate()
26        print stdout
27
28        proc = Popen([sys.executable, 'runme.py', 'Simple_builtin'], stdout=PIPE)
29        (stdout, stderr) = proc.communicate()
30        print stdout