cache misses
public text v1 · immutableint main(void) {
matrix::point3 p(0.0,0.0,0.0);
const int SIZE = 100000;
matrix::point3* a = new matrix::point3[SIZE];
matrix::point3* b = new matrix::point3[SIZE];
for (int i = 0; i < SIZE; ++i) {
a[i] = matrix::point3(i, i+1, i+2);
b[i] = matrix::point3(i+3, i+4, i+5);
}
// loop doing the work - gives SIZE/2 cache misses
for (int i =0; i < SIZE; i+=2) {
a[i] = a[i] + b[i];
a[i+1] = a[i+1] + b[i+1];
}
return 0;
}