File: hash.c

package info (click to toggle)
aflplusplus 4.21c-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,496 kB
  • sloc: ansic: 110,361; cpp: 16,725; sh: 4,855; python: 3,793; makefile: 963; javascript: 515; java: 43; sql: 3; xml: 1
file content (53 lines) | stat: -rw-r--r-- 1,220 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#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;

}