changeset 1135:c47c7f119808

Use finish() only to print benchmark results.
author Marcel Keller <mkeller@cs.au.dk>
date Tue, 17 Feb 2009 10:55:15 +0100
parents 56d259ed2a3d
children 72b7a0717627
files viff/aes.py
diffstat 1 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/viff/aes.py	Mon Feb 16 19:32:31 2009 +0100
+++ b/viff/aes.py	Tue Feb 17 10:55:15 2009 +0100
@@ -21,6 +21,7 @@
 
 
 import time
+import operator
 
 from viff.field import GF256
 from viff.runtime import Share
@@ -350,21 +351,20 @@
 
             get_last(state).addCallback(progress, self.rounds, time.time())
 
-            get_trigger(state).addCallback(finish, state)
+            if (benchmark):
+                get_trigger(state).addCallback(finish, state)
+
+            # connect to final result
+            for a, b in zip(reduce(operator.add, zip(*state)), result):
+                a.addCallback(b.callback)
 
             prep_progress(self.rounds, start_round)
 
             return _
 
         def finish(_, state):
-            actual_result = [byte for word in zip(*state) for byte in word]
-
-            for a, b in zip(actual_result, result):
-                a.addCallback(b.callback)
-
-            if (benchmark):
-                print "Total preparation time: %f" % preparation
-                print "Total communication time: %f" % communication
+            print "Total preparation time: %f" % preparation
+            print "Total communication time: %f" % communication
 
             return _