[Cryptech-Commits] [sw/libhal] branch master updated: Tweak report output.

git at cryptech.is git at cryptech.is
Sat Mar 31 03:00:06 UTC 2018


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

sra at hactrn.net pushed a commit to branch master
in repository sw/libhal.

The following commit(s) were added to refs/heads/master by this push:
     new 311ea95  Tweak report output.
311ea95 is described below

commit 311ea95e192dacc51b6bdce52b43f6663f7d3a1d
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Fri Mar 30 21:08:39 2018 -0400

    Tweak report output.
    
    Copy ContextManagedUnpacker from latest version of libhal.py so that
    this script won't depend on the current development code.
---
 tests/parallel-signatures.py | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/tests/parallel-signatures.py b/tests/parallel-signatures.py
index a0d2f32..c2ff20a 100755
--- a/tests/parallel-signatures.py
+++ b/tests/parallel-signatures.py
@@ -102,6 +102,12 @@ class PKey(cryptech.libhal.Handle):
         yield self.hsm.pkey_verify(self, data = data, signature = signature)
 
 
+class ContextManagedUnpacker(xdrlib.Unpacker):
+    def __enter__(self):
+        return self
+    def __exit__(self, exc_type, exc_val, exc_tb):
+        self.done()
+
 
 class HSM(cryptech.libhal.HSM):
 
@@ -136,7 +142,7 @@ class HSM(cryptech.libhal.HSM):
             unpacker = cryptech.libhal.slip_decode(unpacker)
             if not unpacker:
                 continue
-            unpacker = cryptech.libhal.ContextManagedUnpacker("".join(unpacker))
+            unpacker = ContextManagedUnpacker("".join(unpacker))
             if unpacker.unpack_uint() == code:
                 break
         client = unpacker.unpack_uint()
@@ -222,7 +228,7 @@ def main():
 
     k = key_table[args.key]
     q = Queue()
-    r = Result(args)
+    r = Result(args, args.key)
     
     tbs = pkcs1_hash_and_pad(args.text)
     der = k.exportKey(format = "DER", pkcs = 8)
@@ -247,8 +253,9 @@ def main():
 
 class Result(object):
 
-    def __init__(self, args):
+    def __init__(self, args, name):
         self.args = args
+        self.name = name
         self.sum = datetime.timedelta(seconds = 0)
         self.t0 = datetime.datetime.now()
         self.t1 = None
@@ -274,13 +281,18 @@ class Result(object):
     def sigs_per_sec(self):
         return self.n / (self.t1 - self.t0).total_seconds()
 
+    @property
+    def speedup(self):
+        return (self.t1 - self.t0).total_seconds() / self.sum.total_seconds()
+
     def report(self):
         if self.t1 is None:
             self.t1 = datetime.datetime.now()
-        sys.stdout.write(("\r"
+        sys.stdout.write(("\r{0.name} "
                           "sigs/sec {0.sigs_per_sec} "
                           "secs/sig {0.secs_per_sig} "
                           "mean {0.mean} "
+                          "speedup {0.speedup} "
                           "(n {0.n}, "
                           "t0 {0.t0} "
                           "t1 {0.t1})\n").format(self))

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Commits mailing list