#include <sys/mman.h>
const int size = 0x1 << 25; // 523288 cache lines
+const int iters = 6;
int main(int argc, char **argv) {
char *buf = (char *)mmap(0, size, PROT_READ | PROT_WRITE,
// scheduled. Unfortunately we can't do proper synchronization
// without some form of annotation or something.
sched_yield();
- // Do enough work to get at least 2 samples.
- for (int i = 0; i < size; ++i)
- buf[i] = i;
+ // Do enough work to get at least 4 samples.
+ for (int j = 0; j < iters; ++j) {
+ for (int i = 0; i < size; ++i)
+ buf[i] = i;
+ sched_yield();
+ }
munmap(buf, size);
// We only check for a few samples here to reduce the chance of flakiness.
// CHECK: =={{[0-9]+}}== Total number of samples: {{[0-9]+}}