diff options
author | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2020-11-07 11:02:18 +0200 |
---|---|---|
committer | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2020-12-18 20:24:07 +0200 |
commit | 0e37bb32e215feb4716341f7053c4f54806645cb (patch) | |
tree | 7d2147310be287e8ba640c98c0b709fdd5616b6c | |
parent | c59b5b03a063ebc73935dbb10bc4f568faddbedf (diff) | |
download | libgcrypt-0e37bb32e215feb4716341f7053c4f54806645cb.tar.gz |
tests/bench-slope: use same benchmarking for XTS as for other modes
* tests/bench-slope.c (bench_xts_encrypt_init): Use same buffer
sizes as other tests.
(bench_xts_encrypt_do_bench, bench_xts_decrypt_do_bench): Remove.
(xts_encrypt_ops): Use 'bench_encrypt_do_bench'.
(xts_decrypt_ops): Use 'bench_decrypt_do_bench'.
--
XTS benchmarking was not using same procedure and was not giving
comparable results to, for example, bench-slope-openssl at
'https://github.com/jkivilin/bench-slopes'
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
-rw-r--r-- | tests/bench-slope.c | 65 |
1 files changed, 5 insertions, 60 deletions
diff --git a/tests/bench-slope.c b/tests/bench-slope.c index cfb3dd66..c8647b6b 100644 --- a/tests/bench-slope.c +++ b/tests/bench-slope.c @@ -989,10 +989,9 @@ bench_xts_encrypt_init (struct bench_obj *obj) gcry_cipher_hd_t hd; int err, keylen; - /* For XTS, benchmark with typical data-unit size (512 byte sectors). */ - obj->min_bufsize = 512; - obj->max_bufsize = 16 * obj->min_bufsize; - obj->step_size = obj->min_bufsize; + obj->min_bufsize = BUF_START_SIZE; + obj->max_bufsize = BUF_END_SIZE; + obj->step_size = BUF_STEP_SIZE; obj->num_measure_repetitions = num_measurement_repetitions; err = gcry_cipher_open (&hd, mode->algo, mode->mode, 0); @@ -1035,70 +1034,16 @@ bench_xts_encrypt_init (struct bench_obj *obj) return 0; } -static void -bench_xts_encrypt_do_bench (struct bench_obj *obj, void *buf, size_t buflen) -{ - gcry_cipher_hd_t hd = obj->hd; - unsigned int pos; - static const char tweak[16] = { 0xff, 0xff, 0xfe, }; - size_t sectorlen = obj->step_size; - char *cbuf = buf; - int err; - - gcry_cipher_setiv (hd, tweak, sizeof (tweak)); - - /* Process each sector separately. */ - - for (pos = 0; pos < buflen; pos += sectorlen, cbuf += sectorlen) - { - err = gcry_cipher_encrypt (hd, cbuf, sectorlen, cbuf, sectorlen); - if (err) - { - fprintf (stderr, PGM ": gcry_cipher_encrypt failed: %s\n", - gpg_strerror (err)); - gcry_cipher_close (hd); - exit (1); - } - } -} - -static void -bench_xts_decrypt_do_bench (struct bench_obj *obj, void *buf, size_t buflen) -{ - gcry_cipher_hd_t hd = obj->hd; - unsigned int pos; - static const char tweak[16] = { 0xff, 0xff, 0xfe, }; - size_t sectorlen = obj->step_size; - char *cbuf = buf; - int err; - - gcry_cipher_setiv (hd, tweak, sizeof (tweak)); - - /* Process each sector separately. */ - - for (pos = 0; pos < buflen; pos += sectorlen, cbuf += sectorlen) - { - err = gcry_cipher_decrypt (hd, cbuf, sectorlen, cbuf, sectorlen); - if (err) - { - fprintf (stderr, PGM ": gcry_cipher_encrypt failed: %s\n", - gpg_strerror (err)); - gcry_cipher_close (hd); - exit (1); - } - } -} - static struct bench_ops xts_encrypt_ops = { &bench_xts_encrypt_init, &bench_encrypt_free, - &bench_xts_encrypt_do_bench + &bench_encrypt_do_bench }; static struct bench_ops xts_decrypt_ops = { &bench_xts_encrypt_init, &bench_encrypt_free, - &bench_xts_decrypt_do_bench + &bench_decrypt_do_bench }; |