Created
February 2, 2013 23:20
-
-
Save nremond/4699699 to your computer and use it in GitHub Desktop.
String interpolation benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.testing.Benchmark | |
val a="aaa" | |
val b="bbb" | |
val c="ccc" | |
object Format1 extends Benchmark { | |
def run = String.format("%s - %s - %s\n", a, b, c) | |
} | |
Format1.multiplier = 10000 | |
Format1.runBenchmark(20) | |
object Interp1 extends Benchmark { | |
def run = s"$a - $b - $c\n" | |
} | |
Interp1.multiplier = 10000 | |
Interp1.runBenchmark(20) | |
object Interp2 extends Benchmark { | |
def run = raw"$a - $b - $c" +"\n" | |
} | |
Interp2.multiplier = 10000 | |
Interp2.runBenchmark(20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment