diff --git a/performance/ring/src/main/kotlin/main.kt b/performance/ring/src/main/kotlin/main.kt index 5163a930b85..2ae574ff344 100644 --- a/performance/ring/src/main/kotlin/main.kt +++ b/performance/ring/src/main/kotlin/main.kt @@ -77,6 +77,7 @@ class RingLauncher : Launcher() { "DefaultArgument.testOneOfEight" to BenchmarkEntryWithInit.create(::DefaultArgumentBenchmark, { testOneOfEight() }), "DefaultArgument.testEightOfEight" to BenchmarkEntryWithInit.create(::DefaultArgumentBenchmark, { testEightOfEight() }), "Elvis.testElvis" to BenchmarkEntryWithInit.create(::ElvisBenchmark, { testElvis() }), + "Elvis.testCompositeElvis" to BenchmarkEntryWithInit.create(::ElvisBenchmark, { testCompositeElvis() }), "Euler.problem1bySequence" to BenchmarkEntryWithInit.create(::EulerBenchmark, { problem1bySequence() }), "Euler.problem1" to BenchmarkEntryWithInit.create(::EulerBenchmark, { problem1() }), "Euler.problem2" to BenchmarkEntryWithInit.create(::EulerBenchmark, { problem2() }), diff --git a/performance/ring/src/main/kotlin/org/jetbrains/ring/ElvisBenchmark.kt b/performance/ring/src/main/kotlin/org/jetbrains/ring/ElvisBenchmark.kt index 2d09c581679..b77d11d72a1 100644 --- a/performance/ring/src/main/kotlin/org/jetbrains/ring/ElvisBenchmark.kt +++ b/performance/ring/src/main/kotlin/org/jetbrains/ring/ElvisBenchmark.kt @@ -37,4 +37,17 @@ open class ElvisBenchmark { Blackhole.consume(obj?.value ?: 0) } } + + class Composite(val x : Int, val y : Composite?) + + fun check(a : Composite?) : Int { + return a?.y?.x ?: (a?.x ?: 3) + } + + fun testCompositeElvis(): Int { + var result = 0 + for (i in 0..BENCHMARK_SIZE) + result += check(Composite(Random.nextInt(), Composite(Random.nextInt(), null))) + return result + } }