summaryrefslogtreecommitdiff
path: root/tests/benchmark.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2011-02-15 18:37:43 +0100
committerWerner Koch <wk@gnupg.org>2011-02-15 18:37:43 +0100
commitb825c5db17292988d261fefdc83cbc43d97d4b02 (patch)
tree6be065ad0599e797cde0f72afce78c44884d4832 /tests/benchmark.c
parent83f80d39c3feddc7e055525d47dcf3f069801e89 (diff)
downloadlibgcrypt-b825c5db17292988d261fefdc83cbc43d97d4b02.tar.gz
Add asm code to use aeskeygenassist.
However, this code is disabled right now.
Diffstat (limited to 'tests/benchmark.c')
-rw-r--r--tests/benchmark.c70
1 files changed, 55 insertions, 15 deletions
diff --git a/tests/benchmark.c b/tests/benchmark.c
index 465f1b51..536b76a6 100644
--- a/tests/benchmark.c
+++ b/tests/benchmark.c
@@ -54,6 +54,9 @@ static int hash_repetitions;
/* Alignment of the buffers. */
static int buffer_alignment;
+/* Whether to include the keysetup in the cipher timings. */
+static int cipher_with_keysetup;
+
/* Whether fips mode was active at startup. */
static int in_fips_mode;
@@ -619,13 +622,16 @@ cipher_bench ( const char *algoname )
exit (1);
}
- err = gcry_cipher_setkey (hd, key, keylen);
- if (err)
- {
- fprintf (stderr, "gcry_cipher_setkey failed: %s\n",
- gpg_strerror (err));
- gcry_cipher_close (hd);
- exit (1);
+ if (!cipher_with_keysetup)
+ {
+ err = gcry_cipher_setkey (hd, key, keylen);
+ if (err)
+ {
+ fprintf (stderr, "gcry_cipher_setkey failed: %s\n",
+ gpg_strerror (err));
+ gcry_cipher_close (hd);
+ exit (1);
+ }
}
buflen = allocated_buflen;
@@ -634,7 +640,20 @@ cipher_bench ( const char *algoname )
start_timer ();
for (i=err=0; !err && i < repetitions; i++)
- err = gcry_cipher_encrypt ( hd, outbuf, buflen, buf, buflen);
+ {
+ if (cipher_with_keysetup)
+ {
+ err = gcry_cipher_setkey (hd, key, keylen);
+ if (err)
+ {
+ fprintf (stderr, "gcry_cipher_setkey failed: %s\n",
+ gpg_strerror (err));
+ gcry_cipher_close (hd);
+ exit (1);
+ }
+ }
+ err = gcry_cipher_encrypt ( hd, outbuf, buflen, buf, buflen);
+ }
stop_timer ();
printf (" %s", elapsed_time ());
@@ -654,18 +673,34 @@ cipher_bench ( const char *algoname )
exit (1);
}
- err = gcry_cipher_setkey (hd, key, keylen);
- if (err)
+ if (!cipher_with_keysetup)
{
- fprintf (stderr, "gcry_cipher_setkey failed: %s\n",
- gpg_strerror (err));
- gcry_cipher_close (hd);
- exit (1);
+ err = gcry_cipher_setkey (hd, key, keylen);
+ if (err)
+ {
+ fprintf (stderr, "gcry_cipher_setkey failed: %s\n",
+ gpg_strerror (err));
+ gcry_cipher_close (hd);
+ exit (1);
+ }
}
start_timer ();
for (i=err=0; !err && i < repetitions; i++)
- err = gcry_cipher_decrypt ( hd, outbuf, buflen, buf, buflen);
+ {
+ if (cipher_with_keysetup)
+ {
+ err = gcry_cipher_setkey (hd, key, keylen);
+ if (err)
+ {
+ fprintf (stderr, "gcry_cipher_setkey failed: %s\n",
+ gpg_strerror (err));
+ gcry_cipher_close (hd);
+ exit (1);
+ }
+ }
+ err = gcry_cipher_decrypt ( hd, outbuf, buflen, buf, buflen);
+ }
stop_timer ();
printf (" %s", elapsed_time ());
fflush (stdout);
@@ -1119,6 +1154,11 @@ main( int argc, char **argv )
argc--; argv++;
}
}
+ else if (!strcmp (*argv, "--cipher-with-keysetup"))
+ {
+ cipher_with_keysetup = 1;
+ argc--; argv++;
+ }
else if (!strcmp (*argv, "--hash-repetitions"))
{
argc--; argv++;