Introduction
Introduction Statistics Contact Development Disclaimer Help
benchmark-zrand.c - libzahl - big integer library
git clone git://git.suckless.org/libzahl
Log
Files
Refs
README
LICENSE
---
benchmark-zrand.c (777B)
---
1 #include "util.h"
2
3
4 #define BENCHMARK(INSTRUCTION, FAST)\
5 do {\
6 i = FAST ? 1000000L : 1000L;\
7 TIC;\
8 while (i--) {\
9 INSTRUCTION;\
10 }\
11 TOC;\
12 printf("%s: %s %s\n",\
13 #INSTRUCTION, STIME, FAST ? "µs" : "ms");\
14 } while (0)
15
16
17 int
18 main(int argc, char *argv[])
19 {
20 z_t r, n;
21 jmp_buf jmp;
22 size_t i;
23
24 benchmark_init();
25
26 if (setjmp(jmp)) {
27 zperror(argv[0]);
28 return 1;
29 }
30 zsetup(jmp);
31 zinit(r);
32 zinit(n);
33
34 zsetu(n, 1);
35 zlsh(n, n, 64000L - 1L);
36 zset(r, n);
37
38 BENCHMARK(zrand(r, FAST_RANDOM, MODUNIFORM, n), 0);
39 BENCHMARK(zrand(r, LIBC_RAND_RANDOM, MODUNIFORM, n), 0);
40 BENCHMARK(zrand(r, LIBC_RANDOM_RANDOM, MODUNIFORM, n), 0);
41 BENCHMARK(zrand(r, LIBC_RAND48_RANDOM, MODUNIFORM, n), 0);
42
43 zfree(r);
44 zfree(n);
45 zunsetup();
46 return 0;
47 (void) argc;
48 }
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.