6 |
|
|
7 |
|
|
8 |
import sys |
import sys |
|
sys.path.insert(0, ".") |
|
9 |
import vob |
import vob |
10 |
import vob.util |
vob = sys.modules["vob"] |
11 |
|
|
12 |
import sys, types, traceback |
import sys, types, traceback |
13 |
|
|
74 |
def runPureBench(func, args): |
def runPureBench(func, args): |
75 |
for ar in _argLists(args): |
for ar in _argLists(args): |
76 |
# Precompile for JIT |
# Precompile for JIT |
77 |
func(1, ar) |
func(1, **ar) |
78 |
func(1, ar) |
func(1, **ar) |
79 |
func(1, ar) |
func(1, **ar) |
80 |
|
|
81 |
total = 0 |
total = 0 |
82 |
iters = 1 |
iters = 1 |
83 |
while total < 2.0: |
while total < 2.0: |
84 |
iters *= 2 |
iters *= 2 |
85 |
(total, str) = func(iters, **ar) |
(total, str) = func(iters, **ar) |
86 |
ms = total / iters * 1000 |
ms = total * 1. / iters * 1000 |
87 |
print str |
print str |
88 |
|
print ar |
89 |
print ms, "ms with ",iters," in ",total |
print ms, "ms with ",iters," in ",total |
90 |
print 1000.0 / ms,"per second\n" |
print 1000.0 / ms,"per second\n" |
91 |
|
|
92 |
|
|
93 |
if __name__ == "__main__": |
import getopt |
94 |
import getopt |
print dir(vob) |
95 |
print dir(vob) |
print dir(vob.putil) |
96 |
print dir(vob.putil) |
print dir(vob.util) |
97 |
print dir(vob.util) |
opts, args = getopt.getopt(sys.argv[1:], |
98 |
opts, args = getopt.getopt(sys.argv[1:], |
vob.putil.dbg.short, |
99 |
vob.putil.dbg.short, |
vob.putil.dbg.long) |
100 |
vob.putil.dbg.long) |
for o,a in opts: |
101 |
for o,a in opts: |
print "Opt: ",o,a |
102 |
print "Opt: ",o,a |
vob.putil.dbg.option(o,a) |
103 |
vob.putil.dbg.option(o,a) |
|
104 |
|
# testmod = "bench.vob.text.overhead" |
105 |
# testmod = "bench.vob.text.overhead" |
# testmod = "bench.vob.paper.dice" |
106 |
# testmod = "bench.vob.paper.dice" |
# testmod = "bench.vob.trans.trivial" |
107 |
# testmod = "bench.vob.trans.trivial" |
testmod = args[0] |
108 |
testmod = args[0] |
print "TESTMOD: ",testmod |
109 |
print "TESTMOD: ",testmod |
|
110 |
|
|
111 |
|
|
112 |
|
class Starter(java.lang.Runnable): |
113 |
|
def run(self): |
114 |
|
exec "import "+testmod+"\ntestmod = "+testmod+"\n" |
115 |
|
try: |
116 |
|
if hasattr(testmod, "benchScene"): |
117 |
|
runVSBench(testmod.benchScene, testmod.args) |
118 |
|
else: |
119 |
|
runPureBench(testmod.bench, testmod.args) |
120 |
|
except: |
121 |
|
typ, val, tra = sys.exc_info() |
122 |
|
print (repr((typ, val))) |
123 |
|
print str(val) |
124 |
|
l = traceback.format_list(traceback.extract_tb(tra)) |
125 |
|
print "\n".join(l) |
126 |
|
print "Calling system.exit" |
127 |
|
java.lang.System.exit(0) |
128 |
|
vob.GraphicsAPI.getInstance().startUpdateManager(Starter()) |
129 |
|
|
|
class Starter(java.lang.Runnable): |
|
|
def run(self): |
|
|
exec "import "+testmod+"\ntestmod = "+testmod+"\n" |
|
|
try: |
|
|
if hasattr(testmod, "benchScene"): |
|
|
runVSBench(testmod.benchScene, testmod.args) |
|
|
else: |
|
|
runPureBench(testmod.bench, testmod.args) |
|
|
except: |
|
|
typ, val, tra = sys.exc_info() |
|
|
print (repr((typ, val))) |
|
|
print str(val) |
|
|
l = traceback.format_list(traceback.extract_tb(tra)) |
|
|
print "\n".join(l) |
|
|
print "Calling system.exit" |
|
|
java.lang.System.exit(0) |
|
|
vob.GraphicsAPI.getInstance().startUpdateManager(Starter()) |
|
|
|
|
130 |
|
|
131 |
# 4 cases: |
# 4 cases: |
132 |
# run(None, { "a": (1,2), "b": (3,4), "c": 5 }) |
# run(None, { "a": (1,2), "b": (3,4), "c": 5 }) |