diff options
author | vanhauser-thc <vh@thc.org> | 2024-02-08 12:46:00 +0100 |
---|---|---|
committer | vanhauser-thc <vh@thc.org> | 2024-02-08 12:46:08 +0100 |
commit | 038fef962c3d85fe7e37fcd8717270654f927881 (patch) | |
tree | 03a7e572705e1d2ec813822b1ad09bfff1a39a2c /utils/bench/hash.c | |
parent | 42c663e7c76bd3abee2c6a84dd689bcfea3f59dc (diff) | |
download | afl++-038fef962c3d85fe7e37fcd8717270654f927881.tar.gz |
performance
Diffstat (limited to 'utils/bench/hash.c')
-rw-r--r-- | utils/bench/hash.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/utils/bench/hash.c b/utils/bench/hash.c new file mode 100644 index 00000000..013a5321 --- /dev/null +++ b/utils/bench/hash.c @@ -0,0 +1,42 @@ +#include <stdio.h> +#include <stdint.h> +#include <time.h> + +#define T1HA0_AESNI_AVAILABLE 1 +#define T1HA_USE_FAST_ONESHOT_READ 1 +#define T1HA_USE_INDIRECT_FUNCTIONS 1 +#define T1HA_IA32AES_NAME t1ha0_ia32aes +#include "t1ha0_ia32aes_b.h" + +#define XXH_INLINE_ALL +#include "xxhash.h" +#undef XXH_INLINE_ALL + +int main() { + char *data = malloc(4097); + struct timespec start, end; + long long duration; + int i; + uint64_t res; + + clock_gettime(CLOCK_MONOTONIC, &start); + for (i = 0; i < 100000000; ++i) { + res = XXH3_64bits(data, 4097); + memcpy(data + 16, (char*)&res, 8); + } + clock_gettime(CLOCK_MONOTONIC, &end); + duration = (end.tv_sec - start.tv_sec) * 1000000000LL + (end.tv_nsec - start.tv_nsec); + printf("xxh3 duration: %lld ns\n", duration); + + memset(data, 0, 4097); + clock_gettime(CLOCK_MONOTONIC, &start); + for (i = 0; i < 100000000; ++i) { + res = t1ha0_ia32aes(data, 4097); + memcpy(data + 16, (char*)&res, 8); + } + clock_gettime(CLOCK_MONOTONIC, &end); + duration = (end.tv_sec - start.tv_sec) * 1000000000LL + (end.tv_nsec - start.tv_nsec); + printf("t1ha0_ia32aes duration: %lld ns\n", duration); + + return 0; +} |