These tests demonstrate Spire's generic, in-place sort method going head-to-head with two other implementations: * Java: java.util.Arrays.sort() * Scala: scala.util.Sorting.quickSort() Java has an specialized implementation for each type, which is often a hybrid merge/quick sort (but varies depending on type and situation). Scala manually specializes on int, long, and double, and uses a quicksort implementation. Spire is @specialized on all types using the same source code, and is using a different quicksort implementation. The length number n represents the length log2 (so length = 2^n). thus, 6 means 2^6 (64). Tests were run in Caliper on the same randomized arrays, using Spire's 2.10.0 branch and Scala 2.10.0-M7. The Java version was 1.7.0_04 (build 1.7.0_04-b21), Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode). The Java-x column says how many times faster Spire is. 0.9 means Spire was slower (e.g. Java finished in 90% of Spire's time) and 2.3 means Spire was faster (e.g. Scala finished in 230% of Spire's time). The complex type is Spire's spire.math.Complex class. Since this class doesn't extend Comparator, there is a simpler custom class which does that is used in the Java benchmark. Notice that Spire is faster than Scala in all cases, sometimes by a huge factor. Also notice that Spire sometimes beats Java, even though Java has a heavily optimized algorithm (Spire wins on all floating point arrays, and on small integral arrays). Of course, for non-random arrays the numbers might be more in Java's favor. Still, this is pretty good for ~61 lines of Scala code. ^len type Java(ns) Scala(ns) Spire(ns) Java-x Scala-x 3 int 44.8 53.8 37.1 1.21 1.45 4 int 115.7 129.3 81.2 1.42 1.59 6 int 494.5 787.4 569.7 0.87 1.38 9 int 6202.7 9577.4 5735.6 1.08 1.67 13 int 378704.8 543200.0 422800.8 0.90 1.28 18 int 17908736.8 21772811.6 19272921.6 0.93 1.13 3 long 44.0 502.2 38.2 1.15 13.15 4 long 114.6 1439.3 88.2 1.30 16.32 6 long 494.1 8254.3 536.2 0.92 15.39 9 long 5813.3 101594.4 6531.3 0.89 15.56 13 long 408636.9 2212552.1 417264.9 0.98 5.30 18 long 18040666.7 88102100.0 18946730.8 0.95 4.65 3 float 60.4 81.6 40.7 1.48 2.00 4 float 159.9 177.6 93.2 1.72 1.91 6 float 633.0 1281.5 490.0 1.29 2.62 9 float 6718.1 16124.4 5656.6 1.19 2.85 13 float 410303.8 739364.7 389818.0 1.05 1.90 18 float 18172283.0 31399330.1 17777142.9 1.02 1.77 3 double 64.5 80.9 45.4 1.42 1.78 4 double 156.1 174.4 100.0 1.56 1.74 6 double 692.1 1356.1 493.1 1.40 2.75 9 double 6804.8 22205.3 5876.8 1.16 3.78 13 double 429454.0 743864.3 399452.7 1.08 1.86 18 double 18201085.4 33368724.1 18069433.7 1.01 1.85 3 complex 108.5 440.6 149.6 0.73 2.95 4 complex 274.9 1123.5 501.1 0.55 2.24 6 complex 2075.1 7745.6 2303.1 0.90 3.36 9 complex 35871.9 94059.5 39890.3 0.90 2.36 13 complex 1241035.8 2420025.1 1245536.1 1.00 1.94 18 complex 77393358.3 131548976.2 79469208.3 0.97 1.66