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