diff --git a/performance/src/main/kotlin/org/jetbrains/ring/Utils.kt b/performance/src/main/kotlin-jvm/org/jetbrains/ring/Utils.kt similarity index 94% rename from performance/src/main/kotlin/org/jetbrains/ring/Utils.kt rename to performance/src/main/kotlin-jvm/org/jetbrains/ring/Utils.kt index 4d8aaca0cae..5b8081fe47d 100644 --- a/performance/src/main/kotlin/org/jetbrains/ring/Utils.kt +++ b/performance/src/main/kotlin-jvm/org/jetbrains/ring/Utils.kt @@ -16,12 +16,9 @@ package org.jetbrains.ring -import kotlin.system.measureNanoTime - //-----------------------------------------------------------------------------// class Blackhole { - @konan.ThreadLocal companion object { var consumer = 0 fun consume(value: Any) { @@ -33,7 +30,6 @@ class Blackhole { //-----------------------------------------------------------------------------// class Random() { - @konan.ThreadLocal companion object { var seedInt = 0 fun nextInt(boundary: Int = 100): Int { diff --git a/performance/src/main/kotlin-native/cleanup.kt b/performance/src/main/kotlin-native/cleanup.kt index dd40889bb41..9169f21f2ea 100644 --- a/performance/src/main/kotlin-native/cleanup.kt +++ b/performance/src/main/kotlin-native/cleanup.kt @@ -1,5 +1,5 @@ package org.jetbrains.ring -import konan.internal.GC +import kotlin.native.internal.GC fun cleanup() { GC.collect() } \ No newline at end of file diff --git a/performance/src/main/kotlin-native/org/jetbrains/ring/Utils.kt b/performance/src/main/kotlin-native/org/jetbrains/ring/Utils.kt new file mode 100644 index 00000000000..ee166e73002 --- /dev/null +++ b/performance/src/main/kotlin-native/org/jetbrains/ring/Utils.kt @@ -0,0 +1,48 @@ +/* + * 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 + +//-----------------------------------------------------------------------------// + +class Blackhole { + @kotlin.native.ThreadLocal + companion object { + var consumer = 0 + fun consume(value: Any) { + consumer += value.hashCode() + } + } +} + +//-----------------------------------------------------------------------------// + +class Random() { + @kotlin.native.ThreadLocal + companion object { + var seedInt = 0 + fun nextInt(boundary: Int = 100): Int { + seedInt = (3 * seedInt + 11) % boundary + return seedInt + } + + var seedDouble: Double = 0.1 + fun nextDouble(boundary: Double = 100.0): Double { + seedDouble = (7.0 * seedDouble + 7.0) % boundary + return seedDouble + } + } +}