]> git.codecow.com Git - Monocypher.git/commit
Removed division by zero in speed benchmarks
authorLoup Vaillant <loup@loup-vaillant.fr>
Sun, 17 Feb 2019 18:25:52 +0000 (19:25 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Sun, 17 Feb 2019 18:25:52 +0000 (19:25 +0100)
commit2056365901882345172079ceaec353562804b801
tree7c8dcec593c6001994a36225a941c1303af5115e
parent7b9b7e83784ed23189cb74bfd860067c69da6866
Removed division by zero in speed benchmarks

If some library is so fast that it goes below the resolution of the
timer we're using to measure it, the measured duration may be zero, and
then trigger a division by zero when we convert it to a speed in Hz.

This could possibly happen with a very fast library (Libsodium), on a
very fast machine, with a sufficiently low resolution timer.

This patch reworks and simplifies things a bit, and adds an explicit
check. We now print "too fast to be measured" instead of dividing by
zero.
tests/speed-sodium.c
tests/speed-tweetnacl.c
tests/speed.c
tests/speed.h