aboutsummaryrefslogtreecommitdiffstats
path: root/src/scripts
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-08-10 14:31:49 -0400
committerJack Lloyd <[email protected]>2018-08-10 14:31:49 -0400
commite25b3ace8caa63821fba442dfdb750bcbaa7f39f (patch)
tree11f2daa49b91f0899c2036dd8a3eac68542ac8ac /src/scripts
parent04ee71c5a333d471d6b808ea4be8dd96aadb280f (diff)
Improve speed of cli tests
Exit early from scrypt bench if we only computed a single value in the requested msec bounds. Reduce speed timeouts across board.
Diffstat (limited to 'src/scripts')
-rwxr-xr-xsrc/scripts/test_cli.py86
1 files changed, 49 insertions, 37 deletions
diff --git a/src/scripts/test_cli.py b/src/scripts/test_cli.py
index 1753592cc..353b9ed68 100755
--- a/src/scripts/test_cli.py
+++ b/src/scripts/test_cli.py
@@ -547,7 +547,9 @@ def cli_tls_client_hello_tests():
def cli_speed_tests():
# pylint: disable=too-many-branches
- output = test_cli("speed", ["--msec=1", "--buf-size=64,512", "AES-128"], None).split('\n')
+ msec = 1
+
+ output = test_cli("speed", ["--msec=%d" % (msec), "--buf-size=64,512", "AES-128"], None).split('\n')
if len(output) % 4 != 0:
logging.error("Unexpected number of lines for AES-128 speed test")
@@ -558,7 +560,7 @@ def cli_speed_tests():
if format_re.match(line) is None:
logging.error("Unexpected line %s", line)
- output = test_cli("speed", ["--msec=1", "ChaCha20", "SHA-256", "HMAC(SHA-256)"], None).split('\n')
+ output = test_cli("speed", ["--msec=%d" % (msec), "ChaCha20", "SHA-256", "HMAC(SHA-256)"], None).split('\n')
# pylint: disable=line-too-long
format_re = re.compile(r'^.* buffer size [0-9]+ bytes: [0-9]+\.[0-9]+ MiB\/sec .*\([0-9]+\.[0-9]+ MiB in [0-9]+\.[0-9]+ ms\)')
@@ -566,7 +568,7 @@ def cli_speed_tests():
if format_re.match(line) is None:
logging.error("Unexpected line %s", line)
- output = test_cli("speed", ["--msec=1", "AES-128/GCM"], None).split('\n')
+ output = test_cli("speed", ["--msec=%d" % (msec), "AES-128/GCM"], None).split('\n')
format_re_ks = re.compile(r'^AES-128/GCM\(16\) .* [0-9]+ key schedule/sec; [0-9]+\.[0-9]+ ms/op .*\([0-9]+ (op|ops) in [0-9]+ ms\)')
format_re_cipher = re.compile(r'^AES-128/GCM\(16\) .* buffer size [0-9]+ bytes: [0-9]+\.[0-9]+ MiB\/sec .*\([0-9]+\.[0-9]+ MiB in [0-9]+\.[0-9]+ ms\)')
for line in output:
@@ -578,7 +580,7 @@ def cli_speed_tests():
"DH", "DSA", "ElGamal", "Ed25519", "Curve25519", "NEWHOPE", "McEliece",
"RSA", "XMSS"]
- output = test_cli("speed", ["--msec=5"] + pk_algos, None).split('\n')
+ output = test_cli("speed", ["--msec=%d" % (msec)] + pk_algos, None).split('\n')
# ECDSA-secp256r1 106 keygen/sec; 9.35 ms/op 37489733 cycles/op (1 op in 9 ms)
format_re = re.compile(r'^.* [0-9]+ ([A-Za-z ]+)/sec; [0-9]+\.[0-9]+ ms/op .*\([0-9]+ (op|ops) in [0-9]+ ms\)')
@@ -592,12 +594,12 @@ def cli_speed_tests():
format_re = re.compile(r'^.* [0-9]+ /sec; [0-9]+\.[0-9]+ ms/op .*\([0-9]+ (op|ops) in [0-9]+(\.[0-9]+)? ms\)')
for op in math_ops:
- output = test_cli("speed", ["--msec=15", op], None).split('\n')
+ output = test_cli("speed", ["--msec=%d" % (msec), op], None).split('\n')
for line in output:
if format_re.match(line) is None:
logging.error("Unexpected line %s", line)
- output = test_cli("speed", ["--msec=5", "scrypt"], None).split('\n')
+ output = test_cli("speed", ["--msec=%d" % (msec), "scrypt"], None).split('\n')
format_re = re.compile(r'^scrypt-[0-9]+-[0-9]+-[0-9]+ [0-9]+ /sec; [0-9]+\.[0-9]+ ms/op .*\([0-9]+ (op|ops) in [0-9]+ ms\)')
@@ -605,7 +607,7 @@ def cli_speed_tests():
if format_re.match(line) is None:
logging.error("Unexpected line %s", line)
- output = test_cli("speed", ["--msec=5", "RNG"], None).split('\n')
+ output = test_cli("speed", ["--msec=%d" % (msec), "RNG"], None).split('\n')
# ChaCha_RNG generate buffer size 1024 bytes: 954.431 MiB/sec 4.01 cycles/byte (477.22 MiB in 500.00 ms)
format_re = re.compile(r'^.* generate buffer size [0-9]+ bytes: [0-9]+\.[0-9]+ MiB/sec .*\([0-9]+\.[0-9]+ MiB in [0-9]+\.[0-9]+ ms')
@@ -614,13 +616,13 @@ def cli_speed_tests():
logging.error("Unexpected line %s", line)
# Entropy source rdseed output 128 bytes estimated entropy 0 in 0.02168 ms total samples 32
- output = test_cli("speed", ["--msec=5", "entropy"], None).split('\n')
+ output = test_cli("speed", ["--msec=%d" % (msec), "entropy"], None).split('\n')
format_re = re.compile(r'^Entropy source [_a-z]+ output [0-9]+ bytes estimated entropy [0-9]+ in [0-9]+\.[0-9]+ ms .*total samples [0-9]+')
for line in output:
if format_re.match(line) is None:
logging.error("Unexpected line %s", line)
- output = test_cli("speed", ["--msec=5", "--format=json", "AES-128"], None)
+ output = test_cli("speed", ["--msec=%d" % (msec), "--format=json", "AES-128"], None)
json_blob = json.loads(output)
if len(json_blob) < 2:
@@ -659,34 +661,44 @@ def main(args=None):
start_time = time.time()
- cli_asn1_tests()
- cli_base64_tests()
- cli_bcrypt_tests()
- cli_cc_enc_tests()
- cli_compress_tests()
- cli_config_tests()
- cli_dl_group_info_tests()
- cli_ec_group_info_tests()
- cli_factor_tests()
- cli_gen_dl_group_tests()
- cli_gen_prime_tests()
- cli_hash_tests()
- cli_help_tests()
- cli_hex_tests()
- cli_hmac_tests()
- cli_is_prime_tests()
- cli_key_tests()
- cli_mod_inverse_tests()
- cli_pk_encrypt_tests()
- cli_pk_workfactor_tests()
- cli_psk_db_tests()
- cli_rng_tests()
- cli_speed_tests()
- cli_timing_test_tests()
- cli_tls_ciphersuite_tests()
- cli_tls_client_hello_tests()
- cli_tls_socket_tests()
- cli_version_tests()
+ test_fns = [
+ cli_asn1_tests,
+ cli_asn1_tests,
+ cli_base64_tests,
+ cli_bcrypt_tests,
+ cli_cc_enc_tests,
+ cli_compress_tests,
+ cli_config_tests,
+ cli_dl_group_info_tests,
+ cli_ec_group_info_tests,
+ cli_factor_tests,
+ cli_gen_dl_group_tests,
+ cli_gen_prime_tests,
+ cli_hash_tests,
+ cli_help_tests,
+ cli_hex_tests,
+ cli_hmac_tests,
+ cli_is_prime_tests,
+ cli_key_tests,
+ cli_mod_inverse_tests,
+ cli_pk_encrypt_tests,
+ cli_pk_workfactor_tests,
+ cli_psk_db_tests,
+ cli_rng_tests,
+ cli_speed_tests,
+ cli_timing_test_tests,
+ cli_tls_ciphersuite_tests,
+ cli_tls_client_hello_tests,
+ cli_tls_socket_tests,
+ cli_version_tests,
+ ]
+
+ for fn in test_fns:
+ start = time.time()
+ fn()
+ end = time.time()
+ #print("Ran %s in %.02f" % (fn.__name__, end-start))
+
end_time = time.time()