/* Test how fast my laptop can XOR to memory. * * This program runs on my laptop in 4.4 to 4.5 seconds. * * During that time, on one of the four cores, it is looping ten * million times over a thousand-element array of 64-bit words, XORing * each element, for a total of 640 billion bit-XOR operations, or * about 142 billion per second. This means the machine as a whole * (exclusive of the GPU) is capable of about 570 billion bit-XOR * operations per second. */ #include #include #define ARRAY_SIZE(a) (sizeof(a)/sizeof(*a)) long x[1000]; int main() { if (!fread(x, sizeof(x), 1, stdin)) abort(); for (int i = 0; i < 10000000; i++) { for (int j = 1; j < ARRAY_SIZE(x); j++) { x[j] ^= x[j-1]; } x[0] ^= x[ARRAY_SIZE(x)-1]; } if (!fwrite(x, sizeof(x), 1, stdout)) abort(); return 0; }