diff --git a/kotlin-native/performance/ring/src/main/kotlin/main.kt b/kotlin-native/performance/ring/src/main/kotlin/main.kt index b0b23a1a49f..c90e64c6b4c 100644 --- a/kotlin-native/performance/ring/src/main/kotlin/main.kt +++ b/kotlin-native/performance/ring/src/main/kotlin/main.kt @@ -142,6 +142,7 @@ class RingLauncher : Launcher() { "ForLoops.floatArrayLoop" to BenchmarkEntryWithInit.create(::ForLoopsBenchmark, { floatArrayLoop() }), "ForLoops.charArrayLoop" to BenchmarkEntryWithInit.create(::ForLoopsBenchmark, { charArrayLoop() }), "ForLoops.stringLoop" to BenchmarkEntryWithInit.create(::ForLoopsBenchmark, { stringLoop() }), + "ForLoops.stringArrayLoop" to BenchmarkEntryWithInit.create(::ForLoopsBenchmark, { stringArrayLoop() }), "ForLoops.uIntArrayLoop" to BenchmarkEntryWithInit.create(::ForLoopsBenchmark, { uIntArrayLoop() }), "ForLoops.uShortArrayLoop" to BenchmarkEntryWithInit.create(::ForLoopsBenchmark, { uShortArrayLoop() }), "ForLoops.uLongArrayLoop" to BenchmarkEntryWithInit.create(::ForLoopsBenchmark, { uLongArrayLoop() }), diff --git a/kotlin-native/performance/ring/src/main/kotlin/org/jetbrains/ring/ForLoopsBenchmark.kt b/kotlin-native/performance/ring/src/main/kotlin/org/jetbrains/ring/ForLoopsBenchmark.kt index d75e53b1ac8..759576e1f7d 100644 --- a/kotlin-native/performance/ring/src/main/kotlin/org/jetbrains/ring/ForLoopsBenchmark.kt +++ b/kotlin-native/performance/ring/src/main/kotlin/org/jetbrains/ring/ForLoopsBenchmark.kt @@ -16,6 +16,10 @@ class ForLoopsBenchmark { private val string: String = charArray.joinToString() + private val stringArray: Array = Array(BENCHMARK_SIZE) { + it.toString() + } + private val floatArray: FloatArray = FloatArray(BENCHMARK_SIZE) { it.toFloat() } @@ -64,6 +68,14 @@ class ForLoopsBenchmark { return sum } + fun stringArrayLoop(): Long { + var sum = 0L + for (e in stringArray) { + sum += e.length.toLong() + } + return sum + } + fun floatArrayLoop(): Double { var sum = 0.0 for (e in floatArray) {