Skip to content

Commit 07f9512

Browse files
committed
Fix jmh
1 parent 71f2843 commit 07f9512

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/jmh/kotlin/cub/BenchmarkRunner.kt

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,41 @@ import java.util.concurrent.TimeUnit
99
* to see the difference between first iterations and the next ones
1010
* To see the difference, just check Fork: N of 3 sections, e.g.
1111
*
12-
* # Fork: 1 of 3
13-
* Iteration 1: 27041458.000 ns/op
14-
* Iteration 2: 1750.000 ns/op
15-
* Iteration 3: 1750.000 ns/op
16-
* Iteration 4: 625.000 ns/op
17-
* Iteration 5: 1125.000 ns/op
18-
* Iteration 6: 791.000 ns/op
19-
* Iteration 7: 958.000 ns/op
20-
* Iteration 8: 792.000 ns/op
21-
* Iteration 9: 750.000 ns/op
22-
* Iteration 10: 1084.000 ns/op
12+
# Run progress: 50.00% complete, ETA 00:00:00
13+
# Fork: 1 of 3
14+
# Warmup Iteration 1: 27579584.000 ns/op
15+
# Warmup Iteration 2: 1333.000 ns/op
16+
# Warmup Iteration 3: 667.000 ns/op
17+
Iteration 1: 625.000 ns/op
18+
Iteration 2: 833.000 ns/op
19+
Iteration 3: 917.000 ns/op
20+
Iteration 4: 625.000 ns/op
21+
Iteration 5: 875.000 ns/op
22+
Iteration 6: 667.000 ns/op
23+
Iteration 7: 708.000 ns/op
24+
Iteration 8: 625.000 ns/op
25+
Iteration 9: 1584.000 ns/op
26+
Iteration 10: 4292.000 ns/op
2327
*
24-
* Here we can see that the first iteration takes more time than all others.
28+
* Here we can see that after several Warmup iterations time is table .
2529
* We see different time between attempts, it is ok since the processor spents time for time measurement operations,
2630
* it affects to the results, but the time here is in nano secs, the difference is not significant.
2731
**/
2832
open class BenchmarkRunner {
2933
companion object {
3034
private const val BENCHMARK_ITERATIONS = 10
3135
private const val BENCHMARK_FORKS = 3
32-
private const val BENCHMARK_WARMUPS = 0
36+
private const val BENCHMARK_WARMUPS = 3
3337
}
3438
@Benchmark
3539
@BenchmarkMode(Mode.SingleShotTime)
3640
@OutputTimeUnit(TimeUnit.NANOSECONDS)
3741
@Measurement(iterations = BENCHMARK_ITERATIONS)
42+
@Warmup(iterations = BENCHMARK_WARMUPS)
3843
@Fork(value = BENCHMARK_FORKS, warmups = BENCHMARK_WARMUPS)
3944
fun solveSudoku() {
4045
val solver = BacktrackingSudokuSolver()
4146
solver.solve()
4247
}
4348
}
49+

0 commit comments

Comments
 (0)