Last active
December 14, 2015 00:49
-
-
Save ryoppy/5001417 to your computer and use it in GitHub Desktop.
ベンチマークを簡単にするUtilのテスト
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
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