/rev/bf991ca28f23
changeset: 1270:bf991ca28f23
user: Janus Dam Nielsen <[email protected]>
date: Fri Oct 09 14:15:05 2009 +0200
summary: Added better timing capability to runtime.
diffstat:
apps/benchmark.py | 3 ---
viff/runtime.py | 14 ++++++++++++--
2 files changed, 12 insertions(+), 5 deletions(-)
diffs (62 lines):
diff -r f91b28a6cbbe -r bf991ca28f23 apps/benchmark.py
--- a/apps/benchmark.py Fri Oct 09 13:04:18 2009 +0200
+++ b/apps/benchmark.py Fri Oct 09 14:15:05 2009 +0200
@@ -358,11 +358,9 @@
needed_data = eval(needed_data)
if options.needed_data != "" and options.pc != "":
- print "A1"
bases = (benchmark,) + (NeededDataBenchmarkStrategy,) + (object,)
options.pc = eval(options.pc)
else:
- print "B1"
bases = (benchmark,) + (SelfcontainedBenchmarkStrategy,) + (object,)
benchmark = type("ExtendedBenchmark", bases, {})
@@ -382,7 +380,6 @@
pre_runtime.addCallback(update_args, options)
def do_benchmark(runtime, operation, benchmark, *args):
- print "db"
benchmark(runtime, operation).benchmark(*args)
pre_runtime.addCallback(do_benchmark, operation, benchmark, needed_data,
options.pc)
diff -r f91b28a6cbbe -r bf991ca28f23 viff/runtime.py
--- a/viff/runtime.py Fri Oct 09 13:04:18 2009 +0200
+++ b/viff/runtime.py Fri Oct 09 14:15:05 2009 +0200
@@ -803,7 +803,14 @@
example of a method fulfilling this interface.
"""
- def update(results, program_counters):
+ def update(results, program_counters, start_time, count, what):
+ stop = time.time()
+
+ print
+ print "Total time used: %.3f sec" % (stop - start_time)
+ print "Time per %s operation: %.0f ms" % (what, 1000*(stop -
start_time) / count)
+ print "*" * 6
+
# We concatenate the sub-lists in results.
results = sum(results, [])
@@ -828,7 +835,10 @@
func = getattr(self, generator)
results = []
items = 0
+ count = 0
+ start_time = time.time()
while items < len(program_counters):
+ count += 1
self.increment_pc()
self.fork_pc()
item_count, result = func(*args,
@@ -837,7 +847,7 @@
results.append(result)
self.unfork_pc()
ready = gatherResults(results)
- ready.addCallback(update, program_counters)
+ ready.addCallback(update, program_counters, start_time, count,
generator)
wait_list.append(ready)
self.unfork_pc()
return DeferredList(wait_list)
_______________________________________________
viff-commits mailing list
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-commits-viff.dk