2 * Copyright 2016, Anton Blanchard, Michael Ellerman, IBM Corp.
3 * Licensed under GPLv2.
13 #define ITERATIONS 5000000
15 #define MEMSIZE (128 * 1024 * 1024)
19 struct timespec ts_start, ts_end;
20 unsigned long i = ITERATIONS;
22 clock_gettime(CLOCK_MONOTONIC, &ts_start);
25 char *c = mmap(NULL, MEMSIZE, PROT_READ|PROT_WRITE,
26 MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
27 FAIL_IF(c == MAP_FAILED);
31 clock_gettime(CLOCK_MONOTONIC, &ts_end);
33 printf("time = %.6f\n", ts_end.tv_sec - ts_start.tv_sec + (ts_end.tv_nsec - ts_start.tv_nsec) / 1e9);
40 return test_harness(test_mmap, "mmap_bench");