Now each test normalized on Kotlin-jvm time

Average value also is average of normalized values
This commit is contained in:
Konstantin Anisimov
2017-08-03 18:15:05 +07:00
committed by KonstantinAnisimov
parent 99218ba65f
commit 91fc291bfa
3 changed files with 353 additions and 201 deletions
+1 -2
View File
@@ -9,6 +9,5 @@ fun main(args: Array<String>) {
numMeasureIterations = args[1].toInt()
}
val average = Launcher(numWarmIterations, numMeasureIterations).runBenchmarks()
println("\nRingAverage: $average\n")
Launcher(numWarmIterations, numMeasureIterations).runBenchmarks()
}
@@ -23,9 +23,9 @@ val BENCHMARK_SIZE = 100
//-----------------------------------------------------------------------------//
class Launcher(val numWarmIterations: Int, val numMeasureIterations: Int) {
val results = mutableListOf<Long>()
val results = mutableMapOf<String, Long>()
fun launch(benchmark: () -> Any?) {
fun launch(benchmark: () -> Any?): Long {
var i = numWarmIterations
var j = numMeasureIterations
@@ -34,22 +34,12 @@ class Launcher(val numWarmIterations: Int, val numMeasureIterations: Int) {
while (j-- > 0) benchmark()
}
val timeNormalized = time / numMeasureIterations
results.add(timeNormalized)
printResult(benchmark.toString(), timeNormalized)
return time / numMeasureIterations
}
//-------------------------------------------------------------------------//
fun printResult(name: String, time: Long) {
val niceName = name.replace(" (Kotlin reflection is not available)", "").padEnd(45, ' ')
val niceTime = time.toString().padStart(10, ' ')
println(" $niceName : $niceTime")
}
//-------------------------------------------------------------------------//
fun runBenchmarks(): Long {
fun runBenchmarks() {
runAbstractMethodBenchmark()
runClassArrayBenchmark()
runClassBaselineBenchmark()
@@ -74,370 +64,356 @@ class Launcher(val numWarmIterations: Int, val numMeasureIterations: Int) {
runSwitchBenchmark()
runWithIndiciesBenchmark()
return average()
printResults()
}
//-------------------------------------------------------------------------//
fun average(): Long {
val total = results.fold(0L) { total, next -> total + next }
return total / results.size
fun printResults() {
var total = 0L
results.forEach {
val normaTime = NormaResults[it.key]
val norma = it.value / normaTime!!
val niceName = it.key.padEnd(50, ' ')
val niceNorma = norma.toString().padStart(10, ' ')
println("$niceName : $niceNorma")
total += norma
}
val average = total / results.size
println("\nRingAverage: $average")
}
//-------------------------------------------------------------------------//
fun runAbstractMethodBenchmark() {
println("\nAbstractMethodBenchmark")
val benchmark = AbstractMethodBenchmark()
launch(benchmark::sortStrings)
launch(benchmark::sortStringsWithComparator)
results["AbstractMethod.sortStrings"] = launch(benchmark::sortStrings)
results["AbstractMethod.sortStringsWithComparator"] = launch(benchmark::sortStringsWithComparator)
}
//-------------------------------------------------------------------------//
fun runClassArrayBenchmark() {
println("\nClassArrayBenchmark")
val benchmark = ClassArrayBenchmark()
benchmark.setup()
launch(benchmark::copy)
launch(benchmark::copyManual)
launch(benchmark::filterAndCount)
launch(benchmark::filterAndMap)
launch(benchmark::filterAndMapManual)
launch(benchmark::filter)
launch(benchmark::filterManual)
launch(benchmark::countFilteredManual)
launch(benchmark::countFiltered)
launch(benchmark::countFilteredLocal)
results["ClassArray.copy"] = launch(benchmark::copy)
results["ClassArray.copyManual"] = launch(benchmark::copyManual)
results["ClassArray.filterAndCount"] = launch(benchmark::filterAndCount)
results["ClassArray.filterAndMap"] = launch(benchmark::filterAndMap)
results["ClassArray.filterAndMapManual"] = launch(benchmark::filterAndMapManual)
results["ClassArray.filter"] = launch(benchmark::filter)
results["ClassArray.filterManual"] = launch(benchmark::filterManual)
results["ClassArray.countFilteredManual"] = launch(benchmark::countFilteredManual)
results["ClassArray.countFiltered"] = launch(benchmark::countFiltered)
results["ClassArray.countFilteredLocal"] = launch(benchmark::countFilteredLocal)
}
//-------------------------------------------------------------------------//
fun runClassBaselineBenchmark() {
println("\nClassBaselineBenchmark")
val benchmark = ClassBaselineBenchmark()
launch(benchmark::consume)
launch(benchmark::consumeField)
launch(benchmark::allocateList)
launch(benchmark::allocateArray)
launch(benchmark::allocateListAndFill)
launch(benchmark::allocateListAndWrite)
launch(benchmark::allocateArrayAndFill)
results["ClassBaseline.consume"] = launch(benchmark::consume)
results["ClassBaseline.consumeField"] = launch(benchmark::consumeField)
results["ClassBaseline.allocateList"] = launch(benchmark::allocateList)
results["ClassBaseline.allocateArray"] = launch(benchmark::allocateArray)
results["ClassBaseline.allocateListAndFill"] = launch(benchmark::allocateListAndFill)
results["ClassBaseline.allocateListAndWrite"] = launch(benchmark::allocateListAndWrite)
results["ClassBaseline.allocateArrayAndFill"] = launch(benchmark::allocateArrayAndFill)
}
//-------------------------------------------------------------------------//
fun runClassListBenchmark() {
println("\nClassListBenchmark")
val benchmark = ClassListBenchmark()
benchmark.setup()
launch(benchmark::copy)
launch(benchmark::copyManual)
launch(benchmark::filterAndCount)
launch(benchmark::filterAndCountWithLambda)
launch(benchmark::filterWithLambda)
launch(benchmark::mapWithLambda)
launch(benchmark::countWithLambda)
launch(benchmark::filterAndMapWithLambda)
launch(benchmark::filterAndMapWithLambdaAsSequence)
launch(benchmark::filterAndMap)
launch(benchmark::filterAndMapManual)
launch(benchmark::filter)
launch(benchmark::filterManual)
launch(benchmark::countFilteredManual)
launch(benchmark::countFiltered)
launch(benchmark::reduce)
results["ClassList.copy"] = launch(benchmark::copy)
results["ClassList.copyManual"] = launch(benchmark::copyManual)
results["ClassList.filterAndCount"] = launch(benchmark::filterAndCount)
results["ClassList.filterAndCountWithLambda"] = launch(benchmark::filterAndCountWithLambda)
results["ClassList.filterWithLambda"] = launch(benchmark::filterWithLambda)
results["ClassList.mapWithLambda"] = launch(benchmark::mapWithLambda)
results["ClassList.countWithLambda"] = launch(benchmark::countWithLambda)
results["ClassList.filterAndMapWithLambda"] = launch(benchmark::filterAndMapWithLambda)
results["ClassList.filterAndMapWithLambdaAsSequence"] = launch(benchmark::filterAndMapWithLambdaAsSequence)
results["ClassList.filterAndMap"] = launch(benchmark::filterAndMap)
results["ClassList.filterAndMapManual"] = launch(benchmark::filterAndMapManual)
results["ClassList.filter"] = launch(benchmark::filter)
results["ClassList.filterManual"] = launch(benchmark::filterManual)
results["ClassList.countFilteredManual"] = launch(benchmark::countFilteredManual)
results["ClassList.countFiltered"] = launch(benchmark::countFiltered)
results["ClassList.reduce"] = launch(benchmark::reduce)
}
//-------------------------------------------------------------------------//
fun runClassStreamBenchmark() {
println("\nClassStreamBenchmark")
val benchmark = ClassStreamBenchmark()
benchmark.setup()
launch(benchmark::copy)
launch(benchmark::copyManual)
launch(benchmark::filterAndCount)
launch(benchmark::filterAndMap)
launch(benchmark::filterAndMapManual)
launch(benchmark::filter)
launch(benchmark::filterManual)
launch(benchmark::countFilteredManual)
launch(benchmark::countFiltered)
launch(benchmark::reduce)
results["ClassStream.copy"] = launch(benchmark::copy)
results["ClassStream.copyManual"] = launch(benchmark::copyManual)
results["ClassStream.filterAndCount"] = launch(benchmark::filterAndCount)
results["ClassStream.filterAndMap"] = launch(benchmark::filterAndMap)
results["ClassStream.filterAndMapManual"] = launch(benchmark::filterAndMapManual)
results["ClassStream.filter"] = launch(benchmark::filter)
results["ClassStream.filterManual"] = launch(benchmark::filterManual)
results["ClassStream.countFilteredManual"] = launch(benchmark::countFilteredManual)
results["ClassStream.countFiltered"] = launch(benchmark::countFiltered)
results["ClassStream.reduce"] = launch(benchmark::reduce)
}
//-------------------------------------------------------------------------//
fun runCompanionObjectBenchmark() {
println("\nCompanionObjectBenchmark")
val benchmark = CompanionObjectBenchmark()
launch(benchmark::invokeRegularFunction)
launch(benchmark::invokeJvmStaticFunction)
results["CompanionObject.invokeRegularFunction"] = launch(benchmark::invokeRegularFunction)
results["CompanionObject.invokeJvmStaticFunction"] = launch(benchmark::invokeJvmStaticFunction)
}
//-------------------------------------------------------------------------//
fun runDefaultArgumentBenchmark() {
println("\nDefaultArgumentBenchmark")
val benchmark = DefaultArgumentBenchmark()
benchmark.setup()
launch(benchmark::testOneOfTwo)
launch(benchmark::testTwoOfTwo)
launch(benchmark::testOneOfFour)
launch(benchmark::testFourOfFour)
launch(benchmark::testOneOfEight)
launch(benchmark::testEightOfEight)
results["DefaultArgument.testOneOfTwo"] = launch(benchmark::testOneOfTwo)
results["DefaultArgument.testTwoOfTwo"] = launch(benchmark::testTwoOfTwo)
results["DefaultArgument.testOneOfFour"] = launch(benchmark::testOneOfFour)
results["DefaultArgument.testFourOfFour"] = launch(benchmark::testFourOfFour)
results["DefaultArgument.testOneOfEight"] = launch(benchmark::testOneOfEight)
results["DefaultArgument.testEightOfEight"] = launch(benchmark::testEightOfEight)
}
//-------------------------------------------------------------------------//
fun runElvisBenchmark() {
println("\nElvisBenchmark")
val benchmark = ElvisBenchmark()
benchmark.setup()
launch(benchmark::testElvis)
results["Elvis.testElvis"] = launch(benchmark::testElvis)
}
//-------------------------------------------------------------------------//
fun runEulerBenchmark() {
println("\nEulerBenchmark")
val benchmark = EulerBenchmark()
launch(benchmark::problem1bySequence)
launch(benchmark::problem1)
launch(benchmark::problem2)
launch(benchmark::problem4)
launch(benchmark::problem8)
launch(benchmark::problem9)
launch(benchmark::problem14)
launch(benchmark::problem14full)
results["Euler.problem1bySequence"] = launch(benchmark::problem1bySequence)
results["Euler.problem1"] = launch(benchmark::problem1)
results["Euler.problem2"] = launch(benchmark::problem2)
results["Euler.problem4"] = launch(benchmark::problem4)
results["Euler.problem8"] = launch(benchmark::problem8)
results["Euler.problem9"] = launch(benchmark::problem9)
results["Euler.problem14"] = launch(benchmark::problem14)
results["Euler.problem14full"] = launch(benchmark::problem14full)
}
//-------------------------------------------------------------------------//
fun runFibonacciBenchmark() {
println("\nFibonacciBenchmark")
val benchmark = FibonacciBenchmark()
launch(benchmark::calcClassic)
launch(benchmark::calc)
launch(benchmark::calcWithProgression)
launch(benchmark::calcSquare)
results["Fibonacci.calcClassic"] = launch(benchmark::calcClassic)
results["Fibonacci.calc"] = launch(benchmark::calc)
results["Fibonacci.calcWithProgression"] = launch(benchmark::calcWithProgression)
results["Fibonacci.calcSquare"] = launch(benchmark::calcSquare)
}
//-------------------------------------------------------------------------//
fun runInlineBenchmark() {
println("\nInlineBenchmark")
val benchmark = InlineBenchmark()
launch(benchmark::calculate)
launch(benchmark::calculateInline)
launch(benchmark::calculateGeneric)
launch(benchmark::calculateGenericInline)
results["Inline.calculate"] = launch(benchmark::calculate)
results["Inline.calculateInline"] = launch(benchmark::calculateInline)
results["Inline.calculateGeneric"] = launch(benchmark::calculateGeneric)
results["Inline.calculateGenericInline"] = launch(benchmark::calculateGenericInline)
}
//-------------------------------------------------------------------------//
fun runIntArrayBenchmark() {
println("\nIntArrayBenchmark")
val benchmark = IntArrayBenchmark()
benchmark.setup()
launch(benchmark::copy)
launch(benchmark::copyManual)
launch(benchmark::filterAndCount)
launch(benchmark::filterSomeAndCount)
launch(benchmark::filterAndMap)
launch(benchmark::filterAndMapManual)
launch(benchmark::filter)
launch(benchmark::filterSome)
launch(benchmark::filterPrime)
launch(benchmark::filterManual)
launch(benchmark::filterSomeManual)
launch(benchmark::countFilteredManual)
launch(benchmark::countFilteredSomeManual)
launch(benchmark::countFilteredPrimeManual)
launch(benchmark::countFiltered)
launch(benchmark::countFilteredSome)
launch(benchmark::countFilteredPrime)
launch(benchmark::countFilteredLocal)
launch(benchmark::countFilteredSomeLocal)
launch(benchmark::reduce)
results["IntArray.copy"] = launch(benchmark::copy)
results["IntArray.copyManual"] = launch(benchmark::copyManual)
results["IntArray.filterAndCount"] = launch(benchmark::filterAndCount)
results["IntArray.filterSomeAndCount"] = launch(benchmark::filterSomeAndCount)
results["IntArray.filterAndMap"] = launch(benchmark::filterAndMap)
results["IntArray.filterAndMapManual"] = launch(benchmark::filterAndMapManual)
results["IntArray.filter"] = launch(benchmark::filter)
results["IntArray.filterSome"] = launch(benchmark::filterSome)
results["IntArray.filterPrime"] = launch(benchmark::filterPrime)
results["IntArray.filterManual"] = launch(benchmark::filterManual)
results["IntArray.filterSomeManual"] = launch(benchmark::filterSomeManual)
results["IntArray.countFilteredManual"] = launch(benchmark::countFilteredManual)
results["IntArray.countFilteredSomeManual"] = launch(benchmark::countFilteredSomeManual)
results["IntArray.countFilteredPrimeManual"] = launch(benchmark::countFilteredPrimeManual)
results["IntArray.countFiltered"] = launch(benchmark::countFiltered)
results["IntArray.countFilteredSome"] = launch(benchmark::countFilteredSome)
results["IntArray.countFilteredPrime"] = launch(benchmark::countFilteredPrime)
results["IntArray.countFilteredLocal"] = launch(benchmark::countFilteredLocal)
results["IntArray.countFilteredSomeLocal"] = launch(benchmark::countFilteredSomeLocal)
results["IntArray.reduce"] = launch(benchmark::reduce)
}
//-------------------------------------------------------------------------//
fun runIntBaselineBenchmark() {
println("\nIntBaselineBenchmark")
val benchmark = IntBaselineBenchmark()
launch(benchmark::consume)
launch(benchmark::allocateList)
launch(benchmark::allocateArray)
launch(benchmark::allocateListAndFill)
launch(benchmark::allocateArrayAndFill)
results["IntBaseline.consume"] = launch(benchmark::consume)
results["IntBaseline.allocateList"] = launch(benchmark::allocateList)
results["IntBaseline.allocateArray"] = launch(benchmark::allocateArray)
results["IntBaseline.allocateListAndFill"] = launch(benchmark::allocateListAndFill)
results["IntBaseline.allocateArrayAndFill"] = launch(benchmark::allocateArrayAndFill)
}
//-------------------------------------------------------------------------//
fun runIntListBenchmark() {
println("\nIntListBenchmark")
val benchmark = IntListBenchmark()
benchmark.setup()
launch(benchmark::copy)
launch(benchmark::copyManual)
launch(benchmark::filterAndCount)
launch(benchmark::filterAndMap)
launch(benchmark::filterAndMapManual)
launch(benchmark::filter)
launch(benchmark::filterManual)
launch(benchmark::countFilteredManual)
launch(benchmark::countFiltered)
launch(benchmark::countFilteredLocal)
launch(benchmark::reduce)
results["IntList.copy"] = launch(benchmark::copy)
results["IntList.copyManual"] = launch(benchmark::copyManual)
results["IntList.filterAndCount"] = launch(benchmark::filterAndCount)
results["IntList.filterAndMap"] = launch(benchmark::filterAndMap)
results["IntList.filterAndMapManual"] = launch(benchmark::filterAndMapManual)
results["IntList.filter"] = launch(benchmark::filter)
results["IntList.filterManual"] = launch(benchmark::filterManual)
results["IntList.countFilteredManual"] = launch(benchmark::countFilteredManual)
results["IntList.countFiltered"] = launch(benchmark::countFiltered)
results["IntList.countFilteredLocal"] = launch(benchmark::countFilteredLocal)
results["IntList.reduce"] = launch(benchmark::reduce)
}
//-------------------------------------------------------------------------//
fun runIntStreamBenchmark() {
println("\nIntStreamBenchmark")
val benchmark = IntStreamBenchmark()
benchmark.setup()
launch(benchmark::copy)
launch(benchmark::copyManual)
launch(benchmark::filterAndCount)
launch(benchmark::filterAndMap)
launch(benchmark::filterAndMapManual)
launch(benchmark::filter)
launch(benchmark::filterManual)
launch(benchmark::countFilteredManual)
launch(benchmark::countFiltered)
launch(benchmark::countFilteredLocal)
launch(benchmark::reduce)
results["IntStream.copy"] = launch(benchmark::copy)
results["IntStream.copyManual"] = launch(benchmark::copyManual)
results["IntStream.filterAndCount"] = launch(benchmark::filterAndCount)
results["IntStream.filterAndMap"] = launch(benchmark::filterAndMap)
results["IntStream.filterAndMapManual"] = launch(benchmark::filterAndMapManual)
results["IntStream.filter"] = launch(benchmark::filter)
results["IntStream.filterManual"] = launch(benchmark::filterManual)
results["IntStream.countFilteredManual"] = launch(benchmark::countFilteredManual)
results["IntStream.countFiltered"] = launch(benchmark::countFiltered)
results["IntStream.countFilteredLocal"] = launch(benchmark::countFilteredLocal)
results["IntStream.reduce"] = launch(benchmark::reduce)
}
//-------------------------------------------------------------------------//
fun runLambdaBenchmark() {
println("\nLambdaBenchmark")
val benchmark = LambdaBenchmark()
benchmark.setup()
launch(benchmark::noncapturingLambda)
launch(benchmark::noncapturingLambdaNoInline)
launch(benchmark::capturingLambda)
launch(benchmark::capturingLambdaNoInline)
launch(benchmark::mutatingLambda)
launch(benchmark::mutatingLambdaNoInline)
launch(benchmark::methodReference)
launch(benchmark::methodReferenceNoInline)
results["Lambda.noncapturingLambda"] = launch(benchmark::noncapturingLambda)
results["Lambda.noncapturingLambdaNoInline"] = launch(benchmark::noncapturingLambdaNoInline)
results["Lambda.capturingLambda"] = launch(benchmark::capturingLambda)
results["Lambda.capturingLambdaNoInline"] = launch(benchmark::capturingLambdaNoInline)
results["Lambda.mutatingLambda"] = launch(benchmark::mutatingLambda)
results["Lambda.mutatingLambdaNoInline"] = launch(benchmark::mutatingLambdaNoInline)
results["Lambda.methodReference"] = launch(benchmark::methodReference)
results["Lambda.methodReferenceNoInline"] = launch(benchmark::methodReferenceNoInline)
}
//-------------------------------------------------------------------------//
fun runLoopBenchmark() {
println("\nLoopBenchmark")
val benchmark = LoopBenchmark()
benchmark.setup()
launch(benchmark::arrayLoop)
launch(benchmark::arrayIndexLoop)
launch(benchmark::rangeLoop)
launch(benchmark::arrayListLoop)
launch(benchmark::arrayWhileLoop)
launch(benchmark::arrayForeachLoop)
launch(benchmark::arrayListForeachLoop)
results["Loop.arrayLoop"] = launch(benchmark::arrayLoop)
results["Loop.arrayIndexLoop"] = launch(benchmark::arrayIndexLoop)
results["Loop.rangeLoop"] = launch(benchmark::rangeLoop)
results["Loop.arrayListLoop"] = launch(benchmark::arrayListLoop)
results["Loop.arrayWhileLoop"] = launch(benchmark::arrayWhileLoop)
results["Loop.arrayForeachLoop"] = launch(benchmark::arrayForeachLoop)
results["Loop.arrayListForeachLoop"] = launch(benchmark::arrayListForeachLoop)
}
//-------------------------------------------------------------------------//
fun runMatrixMapBenchmark() {
println("\nMatrixMapBenchmark")
val benchmark = MatrixMapBenchmark()
launch(benchmark::add)
results["MatrixMap.add"] = launch(benchmark::add)
}
//-------------------------------------------------------------------------//
fun runParameterNotNullAssertionBenchmark() {
println("\nParameterNotNullAssertionBenchmark")
val benchmark = ParameterNotNullAssertionBenchmark()
launch(benchmark::invokeOneArgWithNullCheck)
launch(benchmark::invokeOneArgWithoutNullCheck)
launch(benchmark::invokeTwoArgsWithNullCheck)
launch(benchmark::invokeTwoArgsWithoutNullCheck)
launch(benchmark::invokeEightArgsWithNullCheck)
launch(benchmark::invokeEightArgsWithoutNullCheck)
results["ParameterNotNull.invokeOneArgWithNullCheck"] = launch(benchmark::invokeOneArgWithNullCheck)
results["ParameterNotNull.invokeOneArgWithoutNullCheck"] = launch(benchmark::invokeOneArgWithoutNullCheck)
results["ParameterNotNull.invokeTwoArgsWithNullCheck"] = launch(benchmark::invokeTwoArgsWithNullCheck)
results["ParameterNotNull.invokeTwoArgsWithoutNullCheck"] = launch(benchmark::invokeTwoArgsWithoutNullCheck)
results["ParameterNotNull.invokeEightArgsWithNullCheck"] = launch(benchmark::invokeEightArgsWithNullCheck)
results["ParameterNotNull.invokeEightArgsWithoutNullCheck"] = launch(benchmark::invokeEightArgsWithoutNullCheck)
}
//-------------------------------------------------------------------------//
fun runPrimeListBenchmark() {
println("\nPrimeListBenchmark")
val benchmark = PrimeListBenchmark()
launch(benchmark::calcDirect)
launch(benchmark::calcEratosthenes)
results["PrimeList.calcDirect"] = launch(benchmark::calcDirect)
results["PrimeList.calcEratosthenes"] = launch(benchmark::calcEratosthenes)
}
//-------------------------------------------------------------------------//
fun runStringBenchmark() {
println("\nStringBenchmark")
val benchmark = StringBenchmark()
benchmark.setup()
launch(benchmark::stringConcat)
launch(benchmark::stringConcatNullable)
launch(benchmark::stringBuilderConcat)
launch(benchmark::stringBuilderConcatNullable)
launch(benchmark::summarizeSplittedCsv)
results["String.stringConcat"] = launch(benchmark::stringConcat)
results["String.stringConcatNullable"] = launch(benchmark::stringConcatNullable)
results["String.stringBuilderConcat"] = launch(benchmark::stringBuilderConcat)
results["String.stringBuilderConcatNullable"] = launch(benchmark::stringBuilderConcatNullable)
results["String.summarizeSplittedCsv"] = launch(benchmark::summarizeSplittedCsv)
}
//-------------------------------------------------------------------------//
fun runSwitchBenchmark() {
println("\nSwitchBenchmark")
val benchmark = SwitchBenchmark()
benchmark.setupInts()
benchmark.setupStrings()
benchmark.setupEnums()
benchmark.setupSealedClassses()
launch(benchmark::testSparseIntSwitch)
launch(benchmark::testDenseIntSwitch)
launch(benchmark::testConstSwitch)
launch(benchmark::testObjConstSwitch)
launch(benchmark::testVarSwitch)
launch(benchmark::testStringsSwitch)
launch(benchmark::testEnumsSwitch)
launch(benchmark::testDenseEnumsSwitch)
launch(benchmark::testSealedWhenSwitch)
results["Switch.testSparseIntSwitch"] = launch(benchmark::testSparseIntSwitch)
results["Switch.testDenseIntSwitch"] = launch(benchmark::testDenseIntSwitch)
results["Switch.testConstSwitch"] = launch(benchmark::testConstSwitch)
results["Switch.testObjConstSwitch"] = launch(benchmark::testObjConstSwitch)
results["Switch.testVarSwitch"] = launch(benchmark::testVarSwitch)
results["Switch.testStringsSwitch"] = launch(benchmark::testStringsSwitch)
results["Switch.testEnumsSwitch"] = launch(benchmark::testEnumsSwitch)
results["Switch.testDenseEnumsSwitch"] = launch(benchmark::testDenseEnumsSwitch)
results["Switch.testSealedWhenSwitch"] = launch(benchmark::testSealedWhenSwitch)
}
//-------------------------------------------------------------------------//
fun runWithIndiciesBenchmark() {
println("\nWithIndiciesBenchmark")
val benchmark = WithIndiciesBenchmark()
benchmark.setup()
launch(benchmark::withIndicies)
launch(benchmark::withIndiciesManual)
results["WithIndicies.withIndicies"] = launch(benchmark::withIndicies)
results["WithIndicies.withIndiciesManual"] = launch(benchmark::withIndiciesManual)
}
}
@@ -0,0 +1,177 @@
/*
* 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
)