-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcrc32-bench.c
43 lines (34 loc) · 874 Bytes
/
crc32-bench.c
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
/*
* Perform a large number of checksums on random data of given
* size, for timing purpose. Based on crc32_bench.c from:
*
* https://github.com/antonblanchard/crc32-vpmsum
*
* Copyright (C) 2015 Anton Blanchard <[email protected]>, IBM
*
*/
#include <malloc.h>
#include <stdlib.h>
#include <stdio.h>
#include "crc32-s390x.h"
int main(int argc, char *argv[])
{
unsigned long length, iterations;
unsigned char *data;
unsigned long i;
unsigned int crc = 0;
if (argc != 3) {
fprintf(stderr, "Usage: %s length iterations\n", argv[0]);
exit(1);
}
length = strtoul(argv[1], NULL, 0);
iterations = strtoul(argv[2], NULL, 0);
data = memalign(getpagesize(), length);
srandom(1);
for (i = 0; i < length; i++)
data[i] = random() & 0xff;
for (i = 0; i < iterations; i++)
crc = CRC_FUNC(crc, data, length);
printf("CRC: %08x\n", crc);
return 0;
}