Created
February 11, 2013 21:56
-
-
Save andrewconner/4757963 to your computer and use it in GitHub Desktop.
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
def timer(f: => Any): Long = { | |
val startTime = System.nanoTime | |
val ret = f | |
val endTime = System.nanoTime | |
endTime - startTime | |
} | |
def iterTest(f: => Any): Double = { | |
(for(i <- 0 to 10000) yield timer(f)).sorted.apply(5000) | |
} | |
val d_norm = iterTest { | |
running(FakeApplication()) { | |
val translated = route(FakeRequest(GET, "/greet/Barney")).get | |
contentAsString(translated) must contain ("Barney") | |
} | |
} | |
println(s"Normal Play! way:\t$d_norm") | |
val inj_avg = iterTest { | |
running(FakeApplication(withGlobal = Some(FakeTranslatorGlobal))) { | |
val home = route(FakeRequest(GET, "/greet/Barney")).get | |
contentAsString(home) must contain ("Hello Barney") | |
} | |
} | |
println(s"Injected:\t\t$inj_avg") | |
val d_avg = iterTest { | |
val controller = new Translate(new FakeTranslator) | |
val result = controller.greet(name = "Barney")(FakeRequest()) | |
contentAsString(result) must contain ("Hello Barney") | |
} | |
println(s"Direct:\t\t\t$d_avg") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment