aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2018-03-30 23:04:39 -0400
committerRob Austein <sra@hactrn.net>2018-03-30 23:04:39 -0400
commitd8f5f37c2dffab9083fa4c3a89032fabb100f627 (patch)
tree0b90cde073ca3efe3c9bf93209fdce25a272d214 /tests
parent311ea95e192dacc51b6bdce52b43f6663f7d3a1d (diff)
More accurate timing.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/parallel-signatures.py12
1 files 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} "