Skip to content

Commit 31ce90f

Browse files
author
Bytekeeper
committed
Additional frameskip benchmark
1 parent 5e0ee41 commit 31ce90f

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

src/jmh/java/org/bk/ass/SimulatorBenchmark.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
public class SimulatorBenchmark {
1212

1313
@State(Scope.Thread)
14-
public static class MyState {
14+
public static class DefaultSetup {
1515

1616
Simulator simulator;
1717
BWAPI4JAgentFactory factory = new BWAPI4JAgentFactory(null);
@@ -29,6 +29,25 @@ public void setup() {
2929
}
3030
}
3131

32+
@State(Scope.Thread)
33+
public static class WithFrameSkipFour {
34+
35+
Simulator simulator;
36+
BWAPI4JAgentFactory factory = new BWAPI4JAgentFactory(null);
37+
38+
@Setup(Level.Invocation)
39+
public void setup() {
40+
simulator = new Simulator(4);
41+
42+
for (int i = 0; i < 30; i++) {
43+
simulator.addAgentA(factory.of(UnitType.Zerg_Mutalisk));
44+
}
45+
for (int i = 0; i < 30; i++) {
46+
simulator.addAgentB(factory.of(UnitType.Zerg_Hydralisk));
47+
}
48+
}
49+
}
50+
3251
static {
3352
try {
3453
BWDataProvider.injectValues();
@@ -38,12 +57,17 @@ public void setup() {
3857
}
3958

4059
@Benchmark
41-
public int _30MutasVs30Hydras(MyState state) {
60+
public int _30MutasVs30Hydras(DefaultSetup state) {
61+
return state.simulator.simulate(-1);
62+
}
63+
64+
@Benchmark
65+
public int _30MutasVs30Hydras_fs4(WithFrameSkipFour state) {
4266
return state.simulator.simulate(-1);
4367
}
4468

4569
@Benchmark
46-
public int clearCollisionMaps(MyState state) {
70+
public int clearCollisionMaps(DefaultSetup state) {
4771
state.simulator.reset();
4872
return state.simulator.getAgentsA().size() + state.simulator.getAgentsB().size();
4973
}

0 commit comments

Comments
 (0)