Blackhole for native benchmarks (#3251)
This commit is contained in:
@@ -14,6 +14,8 @@ actual class NumericalLauncher : Launcher() {
|
||||
}
|
||||
|
||||
fun jvmBellardPi() {
|
||||
for (n in 1 .. 1000 step 9)
|
||||
pi_nth_digit(n)
|
||||
for (n in 1 .. 1000 step 9) {
|
||||
val result = pi_nth_digit(n)
|
||||
Blackhole.consume(result)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,10 @@ actual class NumericalLauncher : Launcher() {
|
||||
}
|
||||
|
||||
fun konanBellardPi() {
|
||||
for (n in 1 .. 1000 step 9)
|
||||
pi_nth_digit(n)
|
||||
for (n in 1 .. 1000 step 9) {
|
||||
val result = pi_nth_digit(n)
|
||||
Blackhole.consume(result)
|
||||
}
|
||||
}
|
||||
|
||||
fun clangBellardPi() {
|
||||
|
||||
@@ -17,4 +17,4 @@ fun main(args: Array<String>) {
|
||||
arguments.filter, arguments.filterRegex, arguments.verbose)
|
||||
} else emptyList()
|
||||
}, benchmarksListAction = launcher::benchmarksListAction)
|
||||
}
|
||||
}
|
||||
@@ -15,20 +15,6 @@
|
||||
*/
|
||||
|
||||
package org.jetbrains.ring
|
||||
|
||||
import java.io.File
|
||||
|
||||
//-----------------------------------------------------------------------------//
|
||||
|
||||
actual class Blackhole {
|
||||
actual companion object {
|
||||
actual var consumer = 0
|
||||
actual fun consume(value: Any) {
|
||||
consumer += value.hashCode()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------//
|
||||
|
||||
actual class Random actual constructor() {
|
||||
|
||||
@@ -16,20 +16,6 @@
|
||||
|
||||
package org.jetbrains.ring
|
||||
|
||||
import platform.posix.*
|
||||
|
||||
//-----------------------------------------------------------------------------//
|
||||
|
||||
actual class Blackhole {
|
||||
@kotlin.native.ThreadLocal
|
||||
actual companion object {
|
||||
actual var consumer = 0
|
||||
actual fun consume(value: Any) {
|
||||
consumer += value.hashCode()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------//
|
||||
|
||||
actual class Random actual constructor() {
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.ring
|
||||
|
||||
import org.jetbrains.benchmarksLauncher.Blackhole
|
||||
|
||||
open class ClassBaselineBenchmark {
|
||||
|
||||
//Benchmark
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.ring
|
||||
|
||||
import org.jetbrains.benchmarksLauncher.Blackhole
|
||||
|
||||
open class ClassStreamBenchmark {
|
||||
private var _data: Iterable<Value>? = null
|
||||
val data: Iterable<Value>
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.ring
|
||||
|
||||
import org.jetbrains.benchmarksLauncher.Blackhole
|
||||
|
||||
open class ElvisBenchmark {
|
||||
|
||||
class Value(var value: Int)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.ring
|
||||
|
||||
import org.jetbrains.benchmarksLauncher.Blackhole
|
||||
|
||||
open class IntBaselineBenchmark {
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.ring
|
||||
|
||||
import org.jetbrains.benchmarksLauncher.Blackhole
|
||||
|
||||
open class IntStreamBenchmark {
|
||||
private var _data: Iterable<Int>? = null
|
||||
val data: Iterable<Int>
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.ring
|
||||
|
||||
import org.jetbrains.benchmarksLauncher.Blackhole
|
||||
|
||||
open class LoopBenchmark {
|
||||
lateinit var arrayList: List<Value>
|
||||
lateinit var array: Array<Value>
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.ring
|
||||
|
||||
import org.jetbrains.benchmarksLauncher.Blackhole
|
||||
|
||||
val SPARSE_SWITCH_CASES = intArrayOf(11, 29, 47, 71, 103,
|
||||
149, 175, 227, 263, 307,
|
||||
361, 487, 563, 617, 677,
|
||||
|
||||
@@ -18,13 +18,6 @@ package org.jetbrains.ring
|
||||
|
||||
const val BENCHMARK_SIZE = 10000
|
||||
|
||||
expect class Blackhole {
|
||||
companion object {
|
||||
var consumer: Int
|
||||
fun consume(value: Any)
|
||||
}
|
||||
}
|
||||
|
||||
expect class Random() {
|
||||
companion object {
|
||||
var seedInt: Int
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.ring
|
||||
|
||||
import org.jetbrains.benchmarksLauncher.Blackhole
|
||||
|
||||
open class WithIndiciesBenchmark {
|
||||
private var _data: ArrayList<Value>? = null
|
||||
val data: ArrayList<Value>
|
||||
|
||||
@@ -45,3 +45,14 @@ actual fun printStderr(message: String) {
|
||||
actual fun currentTime(): String =
|
||||
SimpleDateFormat("HH:mm:ss").format(Date())
|
||||
|
||||
actual fun nanoTime(): Long = System.nanoTime()
|
||||
|
||||
actual class Blackhole {
|
||||
actual companion object {
|
||||
actual var consumer = 0
|
||||
actual fun consume(value: Any) {
|
||||
consumer += value.hashCode()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
@@ -49,3 +49,14 @@ actual fun printStderr(message: String) {
|
||||
fflush(STDERR)
|
||||
}
|
||||
|
||||
actual fun nanoTime(): Long = kotlin.system.getTimeNanos()
|
||||
|
||||
actual class Blackhole {
|
||||
@kotlin.native.ThreadLocal
|
||||
actual companion object {
|
||||
actual var consumer = 0
|
||||
actual fun consume(value: Any) {
|
||||
consumer += value.hashCode()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,4 +26,13 @@ expect fun cleanup()
|
||||
|
||||
expect fun printStderr(message: String)
|
||||
|
||||
expect fun currentTime(): String
|
||||
expect fun currentTime(): String
|
||||
|
||||
expect fun nanoTime(): Long
|
||||
|
||||
expect class Blackhole {
|
||||
companion object {
|
||||
var consumer: Int
|
||||
fun consume(value: Any)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user