Files
wren/test/benchmark
Robert Nystrom 2a1499b04b Fix horrendously bad bit hashing function.
hashBits() is used to generate a hash code from the same 64 bits used
to represent a Wren number as a double. When building a map containing
a large number of integer keys, it's important for this to do a good
job scattering the bits across the 32-bit key space.

Alas, it does not. Worse, the benchmark to test this happens to stop
just before the performance falls off a cliff, so this was easy to
overlook.

This replaces it with the hash function V8 uses, which has much better
performance across the numeric range.
2019-07-27 13:34:07 -07:00
..
2015-12-23 17:29:53 -08:00
2015-11-11 07:55:48 -08:00
2015-08-27 06:25:24 -07:00
2015-03-14 12:45:56 -07:00
2015-03-14 12:45:56 -07:00
2015-11-11 07:55:48 -08:00
2015-12-15 10:37:53 -08:00
2015-03-14 12:45:56 -07:00
2015-03-14 12:45:56 -07:00
2015-11-11 07:55:48 -08:00
2015-11-11 07:55:48 -08:00
2015-11-11 07:55:48 -08:00
2015-11-11 07:55:48 -08:00

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.