Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Miniboxing Logo

Miniboxing - Reverse Example

This is an example of using the miniboxing plugin in the Scala interpreter. For the benchmark, we reverse a 10M integer array, and compare the performance of the generic version and the miniboxed version.

You get 4-9x speedups by adding a single @miniboxed annotation:

scala> def reverse_gen[T](array: Array[T]): Unit = ...

scala> def reverse_mb[@miniboxed T](array: Array[T]): Unit = ...

scala> benchmark(() => reverse_gen(array))
Time: 32 ms

scala> benchmark(() => reverse_mb(array))
Time: 8 ms

To read the instructions, see http://scala-miniboxing.org/example_reverse.html, the new website for miniboxing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment