Add checkStability to perf tests

This commit is contained in:
Vladimir Dolzhenko
2020-02-19 12:35:59 +01:00
parent a6cf16ddfc
commit 4eb04af01e
3 changed files with 19 additions and 8 deletions
@@ -152,8 +152,8 @@ abstract class AbstractPerformanceProjectsTest : UsefulTestCase() {
assertTrue("path $path does not exist, check README.md", File(projectPath).exists()) assertTrue("path $path does not exist, check README.md", File(projectPath).exists())
val warmUpIterations = if (fast) 0 else 1 val warmUpIterations = if (fast) 0 else 5
val iterations = if (fast) 1 else 3 val iterations = if (fast) 1 else 5
val projectManagerEx = ProjectManagerEx.getInstanceEx() val projectManagerEx = ProjectManagerEx.getInstanceEx()
var lastProject: Project? = null var lastProject: Project? = null
@@ -164,6 +164,7 @@ abstract class AbstractPerformanceProjectsTest : UsefulTestCase() {
stats(stats) stats(stats)
warmUpIterations(warmUpIterations) warmUpIterations(warmUpIterations)
iterations(iterations) iterations(iterations)
checkStability(!fast)
test { test {
val project = if (!simpleModule) { val project = if (!simpleModule) {
val project = loadProjectWithName(name = name, path = path) val project = loadProjectWithName(name = name, path = path)
@@ -14,6 +14,7 @@ class PerfTestBuilder<SV, TV> {
private lateinit var test: (TestData<SV, TV>) -> Unit private lateinit var test: (TestData<SV, TV>) -> Unit
private var tearDown: (TestData<SV, TV>) -> Unit = { } private var tearDown: (TestData<SV, TV>) -> Unit = { }
private var profileEnabled: Boolean = false private var profileEnabled: Boolean = false
private var checkStability: Boolean = true
fun run() { fun run() {
stats.perfTest( stats.perfTest(
@@ -23,7 +24,8 @@ class PerfTestBuilder<SV, TV> {
setUp = setUp, setUp = setUp,
test = test, test = test,
tearDown = tearDown, tearDown = tearDown,
profileEnabled = profileEnabled profileEnabled = profileEnabled,
checkStability = checkStability
) )
} }
@@ -58,6 +60,10 @@ class PerfTestBuilder<SV, TV> {
fun profileEnabled(profileEnabled: Boolean) { fun profileEnabled(profileEnabled: Boolean) {
this.profileEnabled = profileEnabled this.profileEnabled = profileEnabled
} }
fun checkStability(checkStability: Boolean) {
this.checkStability = checkStability
}
} }
fun <SV, TV> performanceTest(initializer: PerfTestBuilder<SV, TV>.() -> Unit) { fun <SV, TV> performanceTest(initializer: PerfTestBuilder<SV, TV>.() -> Unit) {
@@ -20,8 +20,8 @@ typealias StatInfos = Map<String, Any>?
class Stats( class Stats(
val name: String = "", val name: String = "",
val header: Array<String> = arrayOf("Name", "ValueMS", "StdDev"), private val header: Array<String> = arrayOf("Name", "ValueMS", "StdDev"),
val acceptanceStabilityLevel: Int = 25 private val acceptanceStabilityLevel: Int = 25
) : Closeable { ) : Closeable {
private val perfTestRawDataMs = mutableListOf<Long>() private val perfTestRawDataMs = mutableListOf<Long>()
@@ -124,7 +124,8 @@ class Stats(
setUp: (TestData<SV, TV>) -> Unit = { }, setUp: (TestData<SV, TV>) -> Unit = { },
test: (TestData<SV, TV>) -> Unit, test: (TestData<SV, TV>) -> Unit,
tearDown: (TestData<SV, TV>) -> Unit = { }, tearDown: (TestData<SV, TV>) -> Unit = { },
profileEnabled: Boolean = false profileEnabled: Boolean = false,
checkStability: Boolean = true
) { ) {
val warmPhaseData = PhaseData( val warmPhaseData = PhaseData(
@@ -161,10 +162,13 @@ class Stats(
val stable = stabilityPercentage <= acceptanceStabilityLevel val stable = stabilityPercentage <= acceptanceStabilityLevel
printTestStarted(stabilityName) printTestStarted(stabilityName)
printStatValue(stabilityName, stabilityPercentage) printStatValue(stabilityName, stabilityPercentage)
if (stable) { if (stable or !checkStability) {
printTestFinished(stabilityName) printTestFinished(stabilityName)
} else { } else {
printTestFailed(stabilityName, "stability above $stabilityPercentage %") printTestFailed(
stabilityName,
"$testName stability is $stabilityPercentage %, above accepted level of $acceptanceStabilityLevel %"
)
} }
} }
} else { } else {