[Cryptech-Commits] [sw/libhal] 01/02: More accurate timing.

git at cryptech.is git at cryptech.is
Mon Apr 2 13:53:07 UTC 2018


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch rsa-blind-mutation
in repository sw/libhal.

commit d8f5f37c2dffab9083fa4c3a89032fabb100f627
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Fri Mar 30 23:04:39 2018 -0400

    More accurate timing.
---
 tests/parallel-signatures.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tests/parallel-signatures.py b/tests/parallel-signatures.py
index c2ff20a..006b753 100755
--- a/tests/parallel-signatures.py
+++ b/tests/parallel-signatures.py
@@ -228,7 +228,6 @@ def main():
 
     k = key_table[args.key]
     q = Queue()
-    r = Result(args, args.key)
     
     tbs = pkcs1_hash_and_pad(args.text)
     der = k.exportKey(format = "DER", pkcs = 8)
@@ -240,6 +239,8 @@ def main():
 
     pkeys = yield [hsm.pkey_load(der, HAL_KEY_FLAG_USAGE_DIGITALSIGNATURE) for hsm in hsms]
 
+    r = Result(args, args.key)
+
     for pkey in pkeys:
         IOLoop.current().spawn_callback(worker, args, k, pkey, q, r, tbs)
 
@@ -257,11 +258,14 @@ class Result(object):
         self.args = args
         self.name = name
         self.sum = datetime.timedelta(seconds = 0)
-        self.t0 = datetime.datetime.now()
+        self.t0 = None
         self.t1 = None
         self.n = 0
 
     def add(self, t0, t1):
+        if self.t0 is None:
+            self.t0 = t0
+        self.t1 = t1
         delta = t1 - t0
         self.sum += delta
         self.n += 1
@@ -283,11 +287,9 @@ class Result(object):
 
     @property
     def speedup(self):
-        return (self.t1 - self.t0).total_seconds() / self.sum.total_seconds()
+        return  self.sum.total_seconds() / (self.t1 - self.t0).total_seconds()
 
     def report(self):
-        if self.t1 is None:
-            self.t1 = datetime.datetime.now()
         sys.stdout.write(("\r{0.name} "
                           "sigs/sec {0.sigs_per_sec} "
                           "secs/sig {0.secs_per_sig} "



More information about the Commits mailing list