/[libvob]/libvob/bench/mark.py
ViewVC logotype

Diff of /libvob/bench/mark.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by tjl, Tue Apr 15 13:54:20 2003 UTC revision 1.7 by tjl, Thu Apr 24 12:04:57 2003 UTC
# Line 8  Line 8 
8  import sys  import sys
9  sys.path.insert(0, ".")  sys.path.insert(0, ".")
10  import vob  import vob
11    import vob.util
12    
13  import sys, types, traceback  import sys, types, traceback
14    
# Line 35  def _argLists(args): Line 36  def _argLists(args):
36              return _flattenArgLists(args, key)              return _flattenArgLists(args, key)
37      return [args]      return [args]
38    
39  def run(sceneFunc, args):  def runVSBench(sceneFunc, args):
40      """Run the given benchmark with the arguments.      """Run the given benchmark with the arguments.
41    
42      The sceneFunc is assumed to take parameters      The sceneFunc is assumed to take parameters
# Line 71  def run(sceneFunc, args): Line 72  def run(sceneFunc, args):
72          print ms, "ms   with ",iters," in ",total          print ms, "ms   with ",iters," in ",total
73          print 1000.0 / ms,"per second\n"          print 1000.0 / ms,"per second\n"
74    
75    def runPureBench(func, args):
76        for ar in _argLists(args):
77            # Precompile for JIT
78            func(1, ar)
79            func(1, ar)
80            func(1, ar)
81    
82            total = 0
83            iters = 1
84            while total < 2.0:
85                iters *= 2
86                (total, str) = func(iters, **ar)
87                ms = total / iters * 1000
88            print str
89            print ms, "ms   with ",iters," in ",total
90            print 1000.0 / ms,"per second\n"
91                
92    
93  if __name__ == "__main__":  if __name__ == "__main__":
94      import getopt      import getopt
95        print dir(vob)
96        print dir(vob.putil)
97        print dir(vob.util)
98      opts, args = getopt.getopt(sys.argv[1:],      opts, args = getopt.getopt(sys.argv[1:],
99              vob.util.dbg.short,              vob.putil.dbg.short,
100              vob.util.dbg.long)              vob.putil.dbg.long)
101      for o,a in opts:      for o,a in opts:
102          print "Opt: ",o,a          print "Opt: ",o,a
103          vob.util.dbg.option(o,a)          vob.putil.dbg.option(o,a)
104    
105      # testmod = "bench.vob.text.overhead"      # testmod = "bench.vob.text.overhead"
106      # testmod = "bench.vob.paper.dice"      # testmod = "bench.vob.paper.dice"
# Line 92  if __name__ == "__main__": Line 114  if __name__ == "__main__":
114          def run(self):          def run(self):
115              exec "import "+testmod+"\ntestmod = "+testmod+"\n"              exec "import "+testmod+"\ntestmod = "+testmod+"\n"
116              try:              try:
117                  run(testmod.benchScene, testmod.args)                  if hasattr(testmod, "benchScene"):
118                        runVSBench(testmod.benchScene, testmod.args)
119                    else:
120                        runPureBench(testmod.bench, testmod.args)
121              except:              except:
122                  typ, val, tra = sys.exc_info()                  typ, val, tra = sys.exc_info()
123                  print (repr((typ, val)))                  print (repr((typ, val)))

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26