diff options
author | Jean-Remi Desjardins <jeanremi.desjardins@gmail.com> | 2012-12-23 16:44:59 -0500 |
---|---|---|
committer | Jean-Remi Desjardins <jeanremi.desjardins@gmail.com> | 2012-12-23 16:44:59 -0500 |
commit | 02b2da63409af6a28824cbb74d00d0ec04518c8d (patch) | |
tree | b72c244fb5927b985ad166f49823e7f780787b91 /test/files/run | |
parent | 14aa26ca0c346adbc79ccf4c0c9c35bbdd80c201 (diff) | |
download | scala-02b2da63409af6a28824cbb74d00d0ec04518c8d.tar.gz scala-02b2da63409af6a28824cbb74d00d0ec04518c8d.tar.bz2 scala-02b2da63409af6a28824cbb74d00d0ec04518c8d.zip |
SI-5017 Poor performance of :+ operator on Arrays
Control performance of :+ and +: operator on my machine were 700-800 ms
After adding size hint on the implementation in SeqLike, it went down to 500-600 ms
But with specialixed implementation in ArrayOps, brings it down to 300-400 ms
Unfortunatly, this method will only be called when the Array object is being referenced directly as it's type, but that should be the case enough times to justify the extra method.
I ended up removing the sizeHint in SeqLike because it made the execution of the "benchmark" slower when the Array was being manipulated as a Seq.
Side note: Interestingly enough, the benchmark performed better on my virtualized Fedora 17 with JDK 7 than natively on Mac OS X with JDK 6
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/array-addition.check | 4 | ||||
-rw-r--r-- | test/files/run/array-addition.scala | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/test/files/run/array-addition.check b/test/files/run/array-addition.check new file mode 100644 index 0000000000..7bfbd9c711 --- /dev/null +++ b/test/files/run/array-addition.check @@ -0,0 +1,4 @@ +Array(1, 2, 3, 4) +Array(1, 2, 3, 4) +Array(1) +Array(1) diff --git a/test/files/run/array-addition.scala b/test/files/run/array-addition.scala new file mode 100644 index 0000000000..8def48e85c --- /dev/null +++ b/test/files/run/array-addition.scala @@ -0,0 +1,11 @@ +object Test { + def prettyPrintArray(x: Array[_]) = println("Array(" + x.mkString(", ") + ")") + + def main(args: Array[String]): Unit = { + prettyPrintArray(Array(1,2,3) :+ 4) + prettyPrintArray(1 +: Array(2,3,4)) + prettyPrintArray(Array() :+ 1) + prettyPrintArray(1 +: Array()) + } +} + |