The old hashBits function XORed the two 32-bit halves of a double and applied Java HashMap-style mixing, but for small integers the low bits of the double representation are mostly zero, causing nearly all keys to map to entry zero. This replaces it with Thomas Wang's integer hash (as used by V8's ComputeLongHash), which properly scatters bits across the 32-bit key space. Also updates the map_numeric benchmark to iterate 2,000,000 entries (up from 1,000,000) and adjusts the expected output in util/benchmark.py accordingly.
The benchmarks in here attempt to faithfully implement the exact same algorithm in a few different languages. We're using Lua, Python, and Ruby for comparison here because those are all in Wren's ballpark: dynamically-typed, object-oriented, bytecode-compiled.
A bit about each benchmark:
binary_trees
This benchmark stresses object creation and garbage collection. It builds a few big, deeply nested binaries and then traverses them.
fib
This is just a simple naïve Fibonacci number calculator. It was the first benchmark I wrote when Wren supported little more than function calls and arithmetic. It isn't particularly representative of real-world code, but it does stress function call and arithmetic.
for
This microbenchmark just tests the performance of for loops. Not too useful, but i used it when implementing for in Wren to make sure it wasn't too far off the mark.
method_call
This is the most useful benchmark: it tests dynamic dispatch and polymorphism. You'll note that the main iteration loop is unrolled in all of the implementations. This is to ensure that the loop overhead itself doesn't dwarf the method call time.