From cafc30cf760d4db852fa0f134b41d7a92cda8919 Mon Sep 17 00:00:00 2001 From: Igor Chevdar Date: Sat, 28 Apr 2018 14:43:30 +0300 Subject: [PATCH] Some fixes in perf task to make it more reliable --- performance/build.gradle | 8 +- .../org/jetbrains/ring/LambdaBenchmark.kt | 2 +- .../kotlin/org/jetbrains/ring/launcher.kt | 11 +- .../main/kotlin/org/jetbrains/ring/norma.kt | 178 ------------------ 4 files changed, 10 insertions(+), 189 deletions(-) delete mode 100644 performance/src/main/kotlin/org/jetbrains/ring/norma.kt diff --git a/performance/build.gradle b/performance/build.gradle index 6c6f1c5bd6f..9b7a76ccd95 100644 --- a/performance/build.gradle +++ b/performance/build.gradle @@ -95,10 +95,12 @@ task bench(type:DefaultTask) { def konanReport = new Report(project.file("build/konanReport.txt")) def average = "none" def absoluteAverage = "none" - jvmReport.report.each { k, v -> + jvmReport.report + .sort { konanReport.report[it.key] / it.value } + .each { k, v -> def konanValue = konanReport.report[k] - def ratio = String.format('%.2f', konanValue/v) - def formattedKonanValue = String.format('%.2f', konanValue/1000) + def ratio = String.format('%.2f', konanValue / v) + def formattedKonanValue = String.format('%.2f', konanValue / 1000) if (k == 'RingAverage') { average = ratio absoluteAverage = formattedKonanValue diff --git a/performance/src/main/kotlin/org/jetbrains/ring/LambdaBenchmark.kt b/performance/src/main/kotlin/org/jetbrains/ring/LambdaBenchmark.kt index aa4d9003621..4218fabd26a 100644 --- a/performance/src/main/kotlin/org/jetbrains/ring/LambdaBenchmark.kt +++ b/performance/src/main/kotlin/org/jetbrains/ring/LambdaBenchmark.kt @@ -19,7 +19,7 @@ package org.jetbrains.ring var globalAddendum = 0 open class LambdaBenchmark { - private fun runLambda(x: () -> T): T = x() + private inline fun runLambda(x: () -> T): T = x() private fun runLambdaNoInline(x: () -> T): T = x() fun setup() { diff --git a/performance/src/main/kotlin/org/jetbrains/ring/launcher.kt b/performance/src/main/kotlin/org/jetbrains/ring/launcher.kt index cf4c2a6a45c..adef1fbaaba 100644 --- a/performance/src/main/kotlin/org/jetbrains/ring/launcher.kt +++ b/performance/src/main/kotlin/org/jetbrains/ring/launcher.kt @@ -41,7 +41,7 @@ class Launcher(val numWarmIterations: Int) { } cleanup() } - if (time >= 100L * 1_000_000) // 100ms + if (time >= 200L * 1_000_000) // 200ms break autoEvaluatedNumberOfMeasureIteration *= 2 } @@ -103,18 +103,15 @@ class Launcher(val numWarmIterations: Int) { fun printResultsNormalized() { var total = 0.0 results.asSequence().sortedBy { it.key }.forEach { - val normaTime = NormaResults[it.key] - if (normaTime == null) println("ERROR: no norma for benchmark ${it.key}") - - val norma = it.value.toDouble() / normaTime!!.toDouble() + val norma = it.value.toDouble() val niceName = it.key.padEnd(50, ' ') - val niceNorma = norma.toString(2).padStart(10, ' ') + val niceNorma = norma.toString(9) println("$niceName : $niceNorma") total += norma } val average = total / results.size - println("\nRingAverage: ${average.toString(2)}") + println("\nRingAverage: ${average.toString(9)}") } //-------------------------------------------------------------------------// diff --git a/performance/src/main/kotlin/org/jetbrains/ring/norma.kt b/performance/src/main/kotlin/org/jetbrains/ring/norma.kt deleted file mode 100644 index 3988f4cbbea..00000000000 --- a/performance/src/main/kotlin/org/jetbrains/ring/norma.kt +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.ring - -val NormaResults = mapOf( - "AbstractMethod.sortStrings" to 1842L, - "AbstractMethod.sortStringsWithComparator" to 2775L, - "ClassArray.copy" to 148L, - "ClassArray.copyManual" to 456L, - "ClassArray.filterAndCount" to 2197L, - "ClassArray.filterAndMap" to 3081L, - "ClassArray.filterAndMapManual" to 2896L, - "ClassArray.filter" to 2281L, - "ClassArray.filterManual" to 2176L, - "ClassArray.countFilteredManual" to 2403L, - "ClassArray.countFiltered" to 2062L, - "ClassArray.countFilteredLocal" to 2065L, - "ClassBaseline.consume" to 8950L, - "ClassBaseline.consumeField" to 219L, - "ClassBaseline.allocateList" to 48L, - "ClassBaseline.allocateArray" to 30L, - "ClassBaseline.allocateListAndFill" to 6084L, - "ClassBaseline.allocateListAndWrite" to 314L, - "ClassBaseline.allocateArrayAndFill" to 5782L, - "ClassList.copy" to 41L, - "ClassList.copyManual" to 570L, - "ClassList.filterAndCount" to 2260L, - "ClassList.filterAndCountWithLambda" to 573L, - "ClassList.filterWithLambda" to 630L, - "ClassList.mapWithLambda" to 7750L, - "ClassList.countWithLambda" to 151L, - "ClassList.filterAndMapWithLambda" to 4686L, - "ClassList.filterAndMapWithLambdaAsSequence" to 4814L, - "ClassList.filterAndMap" to 3131L, - "ClassList.filterAndMapManual" to 3075L, - "ClassList.filter" to 2342L, - "ClassList.filterManual" to 2347L, - "ClassList.countFilteredManual" to 2186L, - "ClassList.countFiltered" to 2187L, - "ClassList.reduce" to 2208L, - "ClassStream.copy" to 820L, - "ClassStream.copyManual" to 705L, - "ClassStream.filterAndCount" to 2772L, - "ClassStream.filterAndMap" to 3654L, - "ClassStream.filterAndMapManual" to 2894L, - "ClassStream.filter" to 2377L, - "ClassStream.filterManual" to 2206L, - "ClassStream.countFilteredManual" to 2235L, - "ClassStream.countFiltered" to 2466L, - "ClassStream.reduce" to 2211L, - "CompanionObject.invokeRegularFunction" to 5L, - "CompanionObject.invokeJvmStaticFunction" to 5L, - "DefaultArgument.testOneOfTwo" to 5L, - "DefaultArgument.testTwoOfTwo" to 5L, - "DefaultArgument.testOneOfFour" to 5L, - "DefaultArgument.testFourOfFour" to 5L, - "DefaultArgument.testOneOfEight" to 5L, - "DefaultArgument.testEightOfEight" to 5L, - "Elvis.testElvis" to 123L, - "Euler.problem1bySequence" to 345L, - "Euler.problem1" to 143L, - "Euler.problem2" to 143L, - "Euler.problem4" to 66281L, - "Euler.problem8" to 14927L, - "Euler.problem9" to 964L, - "Euler.problem14" to 5327L, - "Euler.problem14full" to 22262L, - "Fibonacci.calcClassic" to 48L, - "Fibonacci.calc" to 48L, - "Fibonacci.calcWithProgression" to 184L, - "Fibonacci.calcSquare" to 5225L, - "Inline.calculate" to 47L, - "Inline.calculateInline" to 43L, - "Inline.calculateGeneric" to 36L, - "Inline.calculateGenericInline" to 31L, - "IntArray.copy" to 578L, - "IntArray.copyManual" to 385L, - "IntArray.filterAndCount" to 3497L, - "IntArray.filterSomeAndCount" to 387L, - "IntArray.filterAndMap" to 3709L, - "IntArray.filterAndMapManual" to 3899L, - "IntArray.filter" to 3605L, - "IntArray.filterSome" to 317L, - "IntArray.filterPrime" to 542L, - "IntArray.filterManual" to 3284L, - "IntArray.filterSomeManual" to 327L, - "IntArray.countFilteredManual" to 3871L, - "IntArray.countFilteredSomeManual" to 194L, - "IntArray.countFilteredPrimeManual" to 438L, - "IntArray.countFiltered" to 3120L, - "IntArray.countFilteredSome" to 194L, - "IntArray.countFilteredPrime" to 436L, - "IntArray.countFilteredLocal" to 3425L, - "IntArray.countFilteredSomeLocal" to 208L, - "IntArray.reduce" to 3210L, - "IntBaseline.consume" to 34L, - "IntBaseline.allocateList" to 37L, - "IntBaseline.allocateArray" to 43L, - "IntBaseline.allocateListAndFill" to 335L, - "IntBaseline.allocateArrayAndFill" to 67L, - "IntList.copy" to 38L, - "IntList.copyManual" to 680L, - "IntList.filterAndCount" to 3470L, - "IntList.filterAndMap" to 3829L, - "IntList.filterAndMapManual" to 3775L, - "IntList.filter" to 3726L, - "IntList.filterManual" to 3376L, - "IntList.countFilteredManual" to 3119L, - "IntList.countFiltered" to 3107L, - "IntList.countFilteredLocal" to 3108L, - "IntList.reduce" to 3114L, - "IntStream.copy" to 984L, - "IntStream.copyManual" to 668L, - "IntStream.filterAndCount" to 3532L, - "IntStream.filterAndMap" to 3948L, - "IntStream.filterAndMapManual" to 3581L, - "IntStream.filter" to 3350L, - "IntStream.filterManual" to 3638L, - "IntStream.countFilteredManual" to 3508L, - "IntStream.countFiltered" to 3337L, - "IntStream.countFilteredLocal" to 3215L, - "IntStream.reduce" to 5399L, - "Lambda.noncapturingLambda" to 224L, - "Lambda.noncapturingLambdaNoInline" to 202L, - "Lambda.capturingLambda" to 26L, - "Lambda.capturingLambdaNoInline" to 26L, - "Lambda.mutatingLambda" to 49L, - "Lambda.mutatingLambdaNoInline" to 49L, - "Lambda.methodReference" to 202L, - "Lambda.methodReferenceNoInline" to 203L, - "Loop.arrayLoop" to 191L, - "Loop.arrayIndexLoop" to 209L, - "Loop.rangeLoop" to 34L, - "Loop.arrayListLoop" to 335L, - "Loop.arrayWhileLoop" to 222L, - "Loop.arrayForeachLoop" to 188L, - "Loop.arrayListForeachLoop" to 298L, - "MatrixMap.add" to 8446L, - "ParameterNotNull.invokeOneArgWithNullCheck" to 5L, - "ParameterNotNull.invokeOneArgWithoutNullCheck" to 5L, - "ParameterNotNull.invokeTwoArgsWithNullCheck" to 5L, - "ParameterNotNull.invokeTwoArgsWithoutNullCheck" to 5L, - "ParameterNotNull.invokeEightArgsWithNullCheck" to 5L, - "ParameterNotNull.invokeEightArgsWithoutNullCheck" to 5L, - "PrimeList.calcDirect" to 860L, - "PrimeList.calcEratosthenes" to 3698L, - "String.stringConcat" to 2212L, - "String.stringConcatNullable" to 9354L, - "String.stringBuilderConcat" to 977L, - "String.stringBuilderConcatNullable" to 951L, - "String.summarizeSplittedCsv" to 31226L, - "Switch.testSparseIntSwitch" to 300L, - "Switch.testDenseIntSwitch" to 283L, - "Switch.testConstSwitch" to 276L, - "Switch.testObjConstSwitch" to 282L, - "Switch.testVarSwitch" to 548L, - "Switch.testStringsSwitch" to 1043L, - "Switch.testEnumsSwitch" to 177L, - "Switch.testDenseEnumsSwitch" to 208L, - "Switch.testSealedWhenSwitch" to 172L, - "WithIndicies.withIndicies" to 2303L, - "WithIndicies.withIndiciesManual" to 2256L, - "OctoTest" to 2515062L -)