Skip to content

Instantly share code, notes, and snippets.

@jrlemieux
Created January 23, 2012 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrlemieux/1665078 to your computer and use it in GitHub Desktop.
Save jrlemieux/1665078 to your computer and use it in GitHub Desktop.
package net.strong_links.fawtests
import scala.collection._
import scala.collection.generic._
object testCollections extends App {
import net.strong_links.core._
def fmt(x: Double) = x.formatted("%.2f")
def run(what: String, n: Long)(f: () => Any) = {
val delta = Util.timerInSeconds(n)(f())
val perSecond = (n.toDouble / delta)
println(" > _: _ millions per second in _ seconds." << (what, fmt(perSecond / 1000000.0), fmt(delta)))
}
def test(title: String, f: () => PluggedString) {
println(title)
run("Create", 800000000L)(() => f())
run("Invoke", 1000000L)(() => f().toString)
}
(0 to 5).foreach { _ =>
test("One args", () => ("Hello _" << "Jacques"))
test("Zero arg", () => ("Hello" << ()))
test("Two args", () => ("Hello _ and _" << ("Jacques", "Maxime")))
test("Four args", () => ("Hello _ _ and _ _" << ("Jacques", "Lemieux", "Maxime", "Lévesque")))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment