Added test harness
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12452 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6bfc86dee7
commit
1e094f865e
22 changed files with 66 additions and 226 deletions
|
|
@ -10,7 +10,7 @@ else
|
||||||
PYSCRIPT = runme3.py
|
PYSCRIPT = runme3.py
|
||||||
endif
|
endif
|
||||||
|
|
||||||
SUBDIRS := constructor func hierarchy operator
|
SUBDIRS := constructor func hierarchy operator hierarchy_operator
|
||||||
|
|
||||||
default : all
|
default : all
|
||||||
|
|
||||||
|
|
@ -36,3 +36,4 @@ $(SUBDIRS) :
|
||||||
$(MAKE) -s -C $* clean
|
$(MAKE) -s -C $* clean
|
||||||
|
|
||||||
clean : $(SUBDIRS:%=%-clean)
|
clean : $(SUBDIRS:%=%-clean)
|
||||||
|
rm -f *.pyc
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,11 @@
|
||||||
#!/usr/bin/env
|
#!/usr/bin/env
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from subprocess import *
|
sys.path.append('..')
|
||||||
|
import harness
|
||||||
|
|
||||||
proc = Popen([sys.executable, 'runme_baseline.py'], stdout=PIPE)
|
def proc (mod) :
|
||||||
(stdout, stderr) = proc.communicate()
|
for i in range(1000000) :
|
||||||
print stdout
|
x = mod.MyClass()
|
||||||
|
|
||||||
proc = Popen([sys.executable, 'runme_optimized.py'], stdout=PIPE)
|
|
||||||
(stdout, stderr) = proc.communicate()
|
|
||||||
print stdout
|
|
||||||
|
|
||||||
proc = Popen([sys.executable, 'runme_builtin.py'], stdout=PIPE)
|
|
||||||
(stdout, stderr) = proc.communicate()
|
|
||||||
print stdout
|
|
||||||
|
|
||||||
|
harness.run(proc)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import Simple_baseline
|
|
||||||
import time
|
|
||||||
|
|
||||||
t1 = time.clock()
|
|
||||||
for i in range(1000000) :
|
|
||||||
x = Simple_baseline.MyClass()
|
|
||||||
#x.func()
|
|
||||||
t2 = time.clock()
|
|
||||||
print "Simple_baseline took %f seconds" % (t2 - t1)
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import Simple_builtin
|
|
||||||
import time
|
|
||||||
|
|
||||||
t1 = time.clock()
|
|
||||||
for i in range(1000000) :
|
|
||||||
x = Simple_builtin.MyClass()
|
|
||||||
#x.func()
|
|
||||||
t2 = time.clock()
|
|
||||||
print "Simple_builtin took %f seconds" % (t2 - t1)
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import Simple_optimized
|
|
||||||
import time
|
|
||||||
|
|
||||||
t1 = time.clock()
|
|
||||||
for i in range(1000000) :
|
|
||||||
x = Simple_optimized.MyClass()
|
|
||||||
#x.func()
|
|
||||||
t2 = time.clock()
|
|
||||||
print "Simple_optimized took %f seconds" % (t2 - t1)
|
|
||||||
|
|
@ -1,17 +1,12 @@
|
||||||
#!/usr/bin/env
|
#!/usr/bin/env
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from subprocess import *
|
sys.path.append('..')
|
||||||
|
import harness
|
||||||
|
|
||||||
proc = Popen([sys.executable, 'runme_baseline.py'], stdout=PIPE)
|
def proc (mod) :
|
||||||
(stdout, stderr) = proc.communicate()
|
x = mod.MyClass()
|
||||||
print stdout
|
for i in range(10000000) :
|
||||||
|
x.func()
|
||||||
proc = Popen([sys.executable, 'runme_optimized.py'], stdout=PIPE)
|
|
||||||
(stdout, stderr) = proc.communicate()
|
|
||||||
print stdout
|
|
||||||
|
|
||||||
proc = Popen([sys.executable, 'runme_builtin.py'], stdout=PIPE)
|
|
||||||
(stdout, stderr) = proc.communicate()
|
|
||||||
print stdout
|
|
||||||
|
|
||||||
|
harness.run(proc)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import Simple_baseline
|
|
||||||
import time
|
|
||||||
|
|
||||||
t1 = time.clock()
|
|
||||||
x = Simple_baseline.MyClass()
|
|
||||||
for i in range(10000000) :
|
|
||||||
x.func()
|
|
||||||
t2 = time.clock()
|
|
||||||
print "Simple_baseline took %f seconds" % (t2 - t1)
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import Simple_builtin
|
|
||||||
import time
|
|
||||||
|
|
||||||
t1 = time.clock()
|
|
||||||
x = Simple_builtin.MyClass()
|
|
||||||
for i in range(10000000) :
|
|
||||||
x.func()
|
|
||||||
t2 = time.clock()
|
|
||||||
print "Simple_builtin took %f seconds" % (t2 - t1)
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import Simple_optimized
|
|
||||||
import time
|
|
||||||
|
|
||||||
t1 = time.clock()
|
|
||||||
x = Simple_optimized.MyClass()
|
|
||||||
for i in range(10000000) :
|
|
||||||
x.func()
|
|
||||||
t2 = time.clock()
|
|
||||||
print "Simple_optimized took %f seconds" % (t2 - t1)
|
|
||||||
30
Examples/python/performance/harness.py
Normal file
30
Examples/python/performance/harness.py
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/usr/bin/env
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import imp
|
||||||
|
from subprocess import *
|
||||||
|
|
||||||
|
def run (proc) :
|
||||||
|
|
||||||
|
try :
|
||||||
|
mod = imp.find_module(sys.argv[1])
|
||||||
|
mod = imp.load_module(sys.argv[1], *mod)
|
||||||
|
|
||||||
|
t1 = time.clock()
|
||||||
|
proc(mod)
|
||||||
|
t2 = time.clock()
|
||||||
|
print "%s took %f seconds" % (mod.__name__, t2 - t1)
|
||||||
|
|
||||||
|
except IndexError :
|
||||||
|
proc = Popen([sys.executable, 'runme.py', 'Simple_baseline'], stdout=PIPE)
|
||||||
|
(stdout, stderr) = proc.communicate()
|
||||||
|
print stdout
|
||||||
|
|
||||||
|
proc = Popen([sys.executable, 'runme.py', 'Simple_optimized'], stdout=PIPE)
|
||||||
|
(stdout, stderr) = proc.communicate()
|
||||||
|
print stdout
|
||||||
|
|
||||||
|
proc = Popen([sys.executable, 'runme.py', 'Simple_builtin'], stdout=PIPE)
|
||||||
|
(stdout, stderr) = proc.communicate()
|
||||||
|
print stdout
|
||||||
|
|
@ -1,17 +1,12 @@
|
||||||
#!/usr/bin/env
|
#!/usr/bin/env
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from subprocess import *
|
sys.path.append('..')
|
||||||
|
import harness
|
||||||
|
|
||||||
proc = Popen([sys.executable, 'runme_baseline.py'], stdout=PIPE)
|
def proc (mod) :
|
||||||
(stdout, stderr) = proc.communicate()
|
x = mod.H()
|
||||||
print stdout
|
for i in range(10000000) :
|
||||||
|
x.func()
|
||||||
proc = Popen([sys.executable, 'runme_optimized.py'], stdout=PIPE)
|
|
||||||
(stdout, stderr) = proc.communicate()
|
|
||||||
print stdout
|
|
||||||
|
|
||||||
proc = Popen([sys.executable, 'runme_builtin.py'], stdout=PIPE)
|
|
||||||
(stdout, stderr) = proc.communicate()
|
|
||||||
print stdout
|
|
||||||
|
|
||||||
|
harness.run(proc)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import Simple_baseline
|
|
||||||
import time
|
|
||||||
|
|
||||||
t1 = time.clock()
|
|
||||||
x = Simple_baseline.H()
|
|
||||||
for i in range(10000000) :
|
|
||||||
x.func()
|
|
||||||
t2 = time.clock()
|
|
||||||
print "Simple_baseline took %f seconds" % (t2 - t1)
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import Simple_builtin
|
|
||||||
import time
|
|
||||||
|
|
||||||
t1 = time.clock()
|
|
||||||
x = Simple_builtin.H()
|
|
||||||
for i in range(10000000) :
|
|
||||||
x.func()
|
|
||||||
t2 = time.clock()
|
|
||||||
print "Simple_builtin took %f seconds" % (t2 - t1)
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import Simple_optimized
|
|
||||||
import time
|
|
||||||
|
|
||||||
t1 = time.clock()
|
|
||||||
x = Simple_optimized.H()
|
|
||||||
for i in range(10000000) :
|
|
||||||
x.func()
|
|
||||||
t2 = time.clock()
|
|
||||||
print "Simple_optimized took %f seconds" % (t2 - t1)
|
|
||||||
|
|
@ -1,17 +1,12 @@
|
||||||
#!/usr/bin/env
|
#!/usr/bin/env
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from subprocess import *
|
sys.path.append('..')
|
||||||
|
import harness
|
||||||
|
|
||||||
proc = Popen([sys.executable, 'runme_baseline.py'], stdout=PIPE)
|
def proc (mod) :
|
||||||
(stdout, stderr) = proc.communicate()
|
x = mod.H()
|
||||||
print stdout
|
for i in range(10000000) :
|
||||||
|
x += i
|
||||||
proc = Popen([sys.executable, 'runme_optimized.py'], stdout=PIPE)
|
|
||||||
(stdout, stderr) = proc.communicate()
|
|
||||||
print stdout
|
|
||||||
|
|
||||||
proc = Popen([sys.executable, 'runme_builtin.py'], stdout=PIPE)
|
|
||||||
(stdout, stderr) = proc.communicate()
|
|
||||||
print stdout
|
|
||||||
|
|
||||||
|
harness.run(proc)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import Simple_baseline
|
|
||||||
import time
|
|
||||||
|
|
||||||
t1 = time.clock()
|
|
||||||
x = Simple_baseline.H()
|
|
||||||
for i in range(10000000) :
|
|
||||||
x += i
|
|
||||||
t2 = time.clock()
|
|
||||||
print "Simple_baseline took %f seconds" % (t2 - t1)
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import Simple_builtin
|
|
||||||
import time
|
|
||||||
|
|
||||||
t1 = time.clock()
|
|
||||||
x = Simple_builtin.H()
|
|
||||||
for i in range(10000000) :
|
|
||||||
x += i
|
|
||||||
t2 = time.clock()
|
|
||||||
print "Simple_builtin took %f seconds" % (t2 - t1)
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import Simple_optimized
|
|
||||||
import time
|
|
||||||
|
|
||||||
t1 = time.clock()
|
|
||||||
x = Simple_optimized.H()
|
|
||||||
for i in range(10000000) :
|
|
||||||
x += i
|
|
||||||
t2 = time.clock()
|
|
||||||
print "Simple_optimized took %f seconds" % (t2 - t1)
|
|
||||||
|
|
@ -1,17 +1,12 @@
|
||||||
#!/usr/bin/env
|
#!/usr/bin/env
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from subprocess import *
|
sys.path.append('..')
|
||||||
|
import harness
|
||||||
|
|
||||||
proc = Popen([sys.executable, 'runme_baseline.py'], stdout=PIPE)
|
def proc (mod) :
|
||||||
(stdout, stderr) = proc.communicate()
|
x = mod.MyClass()
|
||||||
print stdout
|
for i in range(10000000) :
|
||||||
|
x = x + i
|
||||||
proc = Popen([sys.executable, 'runme_optimized.py'], stdout=PIPE)
|
|
||||||
(stdout, stderr) = proc.communicate()
|
|
||||||
print stdout
|
|
||||||
|
|
||||||
proc = Popen([sys.executable, 'runme_builtin.py'], stdout=PIPE)
|
|
||||||
(stdout, stderr) = proc.communicate()
|
|
||||||
print stdout
|
|
||||||
|
|
||||||
|
harness.run(proc)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import Simple_baseline
|
|
||||||
import time
|
|
||||||
|
|
||||||
t1 = time.clock()
|
|
||||||
x = Simple_baseline.MyClass()
|
|
||||||
for i in range(10000000) :
|
|
||||||
x = x + i
|
|
||||||
t2 = time.clock()
|
|
||||||
print "Simple_baseline took %f seconds" % (t2 - t1)
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import Simple_builtin
|
|
||||||
import time
|
|
||||||
|
|
||||||
t1 = time.clock()
|
|
||||||
x = Simple_builtin.MyClass()
|
|
||||||
for i in range(10000000) :
|
|
||||||
x = x + i
|
|
||||||
t2 = time.clock()
|
|
||||||
print "Simple_builtin took %f seconds" % (t2 - t1)
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import Simple_optimized
|
|
||||||
import time
|
|
||||||
|
|
||||||
t1 = time.clock()
|
|
||||||
x = Simple_optimized.MyClass()
|
|
||||||
for i in range(10000000) :
|
|
||||||
x = x + i
|
|
||||||
t2 = time.clock()
|
|
||||||
print "Simple_optimized took %f seconds" % (t2 - t1)
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue