viff

changeset 1270:bf991ca28f23

Added better timing capability to runtime.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Fri, 09 Oct 2009 14:15:05 +0200
parents f91b28a6cbbe
children 26f7a133172a
files apps/benchmark.py viff/runtime.py
diffstat 2 files changed, 12 insertions(+), 5 deletions(-) [+]
line diff
     1.1 --- a/apps/benchmark.py	Fri Oct 09 13:04:18 2009 +0200
     1.2 +++ b/apps/benchmark.py	Fri Oct 09 14:15:05 2009 +0200
     1.3 @@ -358,11 +358,9 @@
     1.4      needed_data = eval(needed_data)
     1.5  
     1.6  if options.needed_data != "" and options.pc != "":
     1.7 -    print "A1"
     1.8      bases = (benchmark,) + (NeededDataBenchmarkStrategy,) + (object,)
     1.9      options.pc = eval(options.pc)
    1.10  else:
    1.11 -    print "B1"
    1.12      bases = (benchmark,) + (SelfcontainedBenchmarkStrategy,) + (object,)
    1.13  benchmark = type("ExtendedBenchmark", bases, {})
    1.14  
    1.15 @@ -382,7 +380,6 @@
    1.16  pre_runtime.addCallback(update_args, options)
    1.17  
    1.18  def do_benchmark(runtime, operation, benchmark, *args):
    1.19 -    print "db"
    1.20      benchmark(runtime, operation).benchmark(*args)
    1.21  
    1.22  pre_runtime.addCallback(do_benchmark, operation, benchmark, needed_data, options.pc)
     2.1 --- a/viff/runtime.py	Fri Oct 09 13:04:18 2009 +0200
     2.2 +++ b/viff/runtime.py	Fri Oct 09 14:15:05 2009 +0200
     2.3 @@ -803,7 +803,14 @@
     2.4          example of a method fulfilling this interface.
     2.5          """
     2.6  
     2.7 -        def update(results, program_counters):
     2.8 +        def update(results, program_counters, start_time, count, what):
     2.9 +            stop = time.time()
    2.10 +
    2.11 +            print
    2.12 +            print "Total time used: %.3f sec" % (stop - start_time)
    2.13 +            print "Time per %s operation: %.0f ms" % (what, 1000*(stop - start_time) / count)
    2.14 +            print "*" * 6
    2.15 +
    2.16              # We concatenate the sub-lists in results.
    2.17              results = sum(results, [])
    2.18  
    2.19 @@ -828,7 +835,10 @@
    2.20              func = getattr(self, generator)
    2.21              results = []
    2.22              items = 0
    2.23 +            count = 0
    2.24 +            start_time = time.time()
    2.25              while items < len(program_counters):
    2.26 +                count += 1
    2.27                  self.increment_pc()
    2.28                  self.fork_pc()
    2.29                  item_count, result = func(*args,
    2.30 @@ -837,7 +847,7 @@
    2.31                  results.append(result)
    2.32                  self.unfork_pc()
    2.33              ready = gatherResults(results)
    2.34 -            ready.addCallback(update, program_counters)
    2.35 +            ready.addCallback(update, program_counters, start_time, count, generator)
    2.36              wait_list.append(ready)
    2.37              self.unfork_pc()
    2.38          return DeferredList(wait_list)