Skip to content

Commit 2916687

Browse files
committed
Add TracePerformance test to compare overhead with Checkpointing
This also adds a breakout game to the test files.
1 parent 00655ab commit 2916687

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package benchmarks
2+
3+
import DebuggerTestBase
4+
import be.ugent.topl.mio.debugger.Debugger
5+
import be.ugent.topl.mio.debugger.ExecutionState
6+
import org.junit.jupiter.api.Test
7+
import java.lang.System.currentTimeMillis
8+
9+
class TracePerformance : DebuggerTestBase() {
10+
@Test
11+
fun `test`() {
12+
val continueForCount = 5 // Was 5 in the paper.
13+
val results = mutableListOf<Result>()
14+
for (policy in listOf(
15+
Debugger.SnapshotPolicy.None(),
16+
Debugger.SnapshotPolicy.Tracing(listOf(ExecutionState.ProgramCounter)),
17+
Debugger.SnapshotPolicy.Checkpointing(0xffff)
18+
)) {
19+
println("Policy $policy")
20+
val pairs = mutableListOf<Pair<Long, Long>>()
21+
runWithDebugger("breakout.wasm", true) { debugger ->
22+
debugger.setSnapshotPolicy(Debugger.SnapshotPolicy.None())
23+
debugger.continueFor(100500)
24+
debugger.setSnapshotPolicy(policy)
25+
var totalTime = 0L
26+
var position = 0L
27+
repeat(continueForCount) {
28+
val startTime = currentTimeMillis()
29+
val offset = 10000
30+
debugger.continueFor(offset)
31+
debugger.checkpoints.clear() // Clear checkpoint data to save memory.
32+
position += offset
33+
totalTime += currentTimeMillis() - startTime
34+
pairs.add(Pair(position, totalTime))
35+
println("$totalTime ms elapsed!")
36+
}
37+
}
38+
println("Data $pairs")
39+
results.add(Result(policy, pairs))
40+
}
41+
println()
42+
println("--- Test results ---")
43+
for (result in results) {
44+
println("${result.policy}: ${result.data}")
45+
}
46+
}
47+
48+
data class Result(val policy: Debugger.SnapshotPolicy, val data: List<Pair<Long, Long>>)
49+
}

src/test/resources/breakout.wasm

9.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)