Hacker News new | ask | show | jobs
by ascar 1926 days ago
This is the benchmarking loop:

  for (size_t i = 0; i < N; i++) {
    out[i++] = g();
  }
N is 20000 and the time measured is divided by N. [1] However, that loop has two increments and only computes 10000 numbers.

This is also visible in the assembly

  add     x8, x8, #2
So if I see this correctly the results are off by a factor of 2.

[1] https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/...

3 comments

Yes, the i++ seems an oversight.

The relative speed between the two hashes is still the same, but it is no longer one iteration per cycle.

> Update: The numbers were updated since they were off by a factor of two due to a typographical error in the code.

The article got updated by now :)

A C for statement is a "benchmarking loop" in the same sense that "slice a sponge cake into two layers and place custard in the middle" is an actionable dessert recipe.