-static int benchmark_siphash(void)
-{
-# ifdef OPENSSL_CPUID_OBJ
- SIPHASH siphash;
- unsigned char key[SIPHASH_KEY_SIZE];
- unsigned char buf[8192];
- unsigned long long stopwatch;
- unsigned long long OPENSSL_rdtsc();
- unsigned int i;
-
- memset (buf,0x55,sizeof(buf));
- memset (key,0xAA,sizeof(key));
-
- (void)SipHash_Init(&siphash, key, 0, 0, 0);
-
- for (i=0;i<100000;i++)
- SipHash_Update(&siphash, buf, sizeof(buf));
-
- stopwatch = OPENSSL_rdtsc();
- for (i=0;i<10000;i++)
- SipHash_Update(&siphash, buf, sizeof(buf));
- stopwatch = OPENSSL_rdtsc() - stopwatch;
-
- BIO_printf(b_stdout, "%g\n",stopwatch/(double)(i*sizeof(buf)));
-
- stopwatch = OPENSSL_rdtsc();
- for (i=0;i<10000;i++) {
- (void)SipHash_Init(&siphash, key, 0, 0, 0);
- SipHash_Update(&siphash, buf, 16);
- (void)SipHash_Final(&siphash, buf, SIPHASH_MAX_DIGEST_SIZE);
- }
- stopwatch = OPENSSL_rdtsc() - stopwatch;
-
- BIO_printf(b_stdout, "%g\n",stopwatch/(double)(i));
-# else
- BIO_printf(b_stderr,
- "Benchmarking of siphash isn't available on this platform\n");
-# endif
- return 1;
-}
-