Skip to content

Instantly share code, notes, and snippets.

@VladUreche
Last active December 25, 2015 00:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VladUreche/6891789 to your computer and use it in GitHub Desktop.
Save VladUreche/6891789 to your computer and use it in GitHub Desktop.

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