Skip to content

Instantly share code, notes, and snippets.

@ryoppy
Last active December 14, 2015 00:49
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 ryoppy/5001417 to your computer and use it in GitHub Desktop.
Save ryoppy/5001417 to your computer and use it in GitHub Desktop.
ベンチマークを簡単にするUtilのテスト
package util
import org.specs2.mutable._
class BenchmarkSpec extends Specification with Before with Benchmark {
def before() = isPrint = false
"loop" should {
"10 times" in {
val resultSet: BenchmarkResultSet = loop(10, { i =>
// something...
})
resultSet.count == 10
}
}
"calcQps" should {
"3000 times in one 1000ms equal 3000QPS is ok" in {
calcQps(3000, 1000) == 3000
}
"1500 times in one 2000ms equal 750QPS is ok" in {
calcQps(1500, 2000) == 750
}
"2000 times in one 1000ms equal 1QPS is ng" in {
calcQps(2000, 1000) != 1 // 2 is correct
}
}
"calcAverage" should {
"30000ms ran 3000 times equal 10 is ok" in {
calcAverageTime(3000, 30000) == 10
}
"10000ms ran 2000 times equal 10 is ok" in {
calcAverageTime(2000, 10000) == 5
}
"20000ms ran 1000 times equal 1 is ng" in {
calcAverageTime(1000, 20000) != 10 // 20 is correct.
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment