Skip to content

Commit 0a36c34

Browse files
author
Abduqodiri Qurbonzoda
authored
Merge pull request #56 from Kotlin/mpp
Decrease stress tests execution time
2 parents d552dba + 2f00671 commit 0a36c34

13 files changed

+713
-381
lines changed

core/build.gradle.kts

-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
2-
31
plugins {
42
id("kotlin-multiplatform")
53
`maven-publish`
@@ -102,9 +100,4 @@ tasks {
102100
maxHeapSize = "1024m"
103101
executable = "$JDK_6/bin/java"
104102
}
105-
106-
withType<KotlinNativeTest>() {
107-
// disable all Kotlin/Native tests: very long running
108-
enabled = false
109-
}
110103
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2016-2019 JetBrains s.r.o.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package tests.stress
18+
19+
import kotlin.test.AfterTest
20+
import kotlin.test.BeforeTest
21+
import kotlin.time.*
22+
23+
@UseExperimental(ExperimentalTime::class)
24+
abstract class ExecutionTimeMeasuringTest {
25+
private var clockMark: ClockMark? = null
26+
27+
private fun markExecutionStart() {
28+
clockMark = MonoClock.markNow()
29+
}
30+
31+
private fun printExecutionTime() {
32+
val nonNullClockMark = clockMark ?: throw IllegalStateException("markExecutionStart() must be called first")
33+
val elapsed = nonNullClockMark.elapsedNow()
34+
35+
if (elapsed > 3.seconds) {
36+
print("#".repeat(20) + " ")
37+
}
38+
println("Execution time: ${elapsed.toString(DurationUnit.MILLISECONDS)}")
39+
40+
clockMark = null
41+
}
42+
43+
@BeforeTest
44+
fun before() {
45+
markExecutionStart()
46+
}
47+
48+
@AfterTest
49+
fun after() {
50+
printExecutionTime()
51+
}
52+
}

core/commonTest/src/stress/ObjectWrapper.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ class ObjectWrapper<K: Comparable<K>>(
3838
override fun compareTo(other: ObjectWrapper<K>): Int {
3939
return obj.compareTo(other.obj)
4040
}
41-
}
41+
}
42+
43+
typealias IntWrapper = ObjectWrapper<Int>

0 commit comments

Comments
 (0)