MCPcopy Create free account
hub / github.com/numpy/numpy / main

Function main

numpy/random/src/pcg64/pcg64-benchmark.c:17–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#define N 1000000000
16
17int main() {
18 pcg64_random_t rng;
19 uint64_t sum = 0, count = 0;
20 uint64_t seed = 0xDEADBEAF;
21 int i;
22#if __SIZEOF_INT128__ && !defined(PCG_FORCE_EMULATED_128BIT_MATH)
23 rng.state = (__uint128_t)splitmix64_next(&seed) << 64;
24 rng.state |= splitmix64_next(&seed);
25 rng.inc = (__uint128_t)1;
26#else
27 rng.state.high = splitmix64_next(&seed);
28 rng.state.low = splitmix64_next(&seed);
29 rng.inc.high = 0;
30 rng.inc.low = 1;
31#endif
32 clock_t begin = clock();
33 for (i = 0; i < N; i++) {
34 sum += pcg64_random_r(&rng);
35 count++;
36 }
37 clock_t end = clock();
38 double time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
39 printf("0x%" PRIx64 "\ncount: %" PRIu64 "\n", sum, count);
40 printf("%" PRIu64 " randoms per second\n",
41 (uint64_t)(N / time_spent) / 1000000 * 1000000);
42}

Callers

nothing calls this directly

Calls 1

splitmix64_nextFunction · 0.85

Tested by

no test coverage detected