diff options
Diffstat (limited to 'store/src/jmh/java/org/eclipse/viatra/solver/data/map/benchmarks/ImmutablePutExecutionPlan.java')
-rw-r--r-- | store/src/jmh/java/org/eclipse/viatra/solver/data/map/benchmarks/ImmutablePutExecutionPlan.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/store/src/jmh/java/org/eclipse/viatra/solver/data/map/benchmarks/ImmutablePutExecutionPlan.java b/store/src/jmh/java/org/eclipse/viatra/solver/data/map/benchmarks/ImmutablePutExecutionPlan.java new file mode 100644 index 00000000..6cac74af --- /dev/null +++ b/store/src/jmh/java/org/eclipse/viatra/solver/data/map/benchmarks/ImmutablePutExecutionPlan.java | |||
@@ -0,0 +1,56 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.benchmarks; | ||
2 | |||
3 | import java.util.Random; | ||
4 | |||
5 | import org.eclipse.viatra.solver.data.map.ContinousHashProvider; | ||
6 | import org.eclipse.viatra.solver.data.map.VersionedMapStore; | ||
7 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; | ||
8 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; | ||
9 | import org.eclipse.viatra.solver.data.map.tests.utils.MapTestEnvironment; | ||
10 | import org.openjdk.jmh.annotations.Level; | ||
11 | import org.openjdk.jmh.annotations.Param; | ||
12 | import org.openjdk.jmh.annotations.Scope; | ||
13 | import org.openjdk.jmh.annotations.Setup; | ||
14 | import org.openjdk.jmh.annotations.State; | ||
15 | |||
16 | @State(Scope.Benchmark) | ||
17 | public class ImmutablePutExecutionPlan { | ||
18 | |||
19 | @Param({ "100", "10000" }) | ||
20 | public int nPut; | ||
21 | |||
22 | @Param({ "32", "1000", "100000" }) | ||
23 | public int nKeys; | ||
24 | |||
25 | @Param({ "2", "3" }) | ||
26 | public int nValues; | ||
27 | |||
28 | private Random random; | ||
29 | |||
30 | private String[] values; | ||
31 | |||
32 | private ContinousHashProvider<Integer> hashProvider = MapTestEnvironment.prepareHashProvider(false); | ||
33 | |||
34 | @Setup(Level.Trial) | ||
35 | public void setUpTrial() { | ||
36 | random = new Random(); | ||
37 | values = MapTestEnvironment.prepareValues(nValues); | ||
38 | } | ||
39 | |||
40 | public VersionedMapImpl<Integer, String> createSut() { | ||
41 | VersionedMapStore<Integer, String> store = new VersionedMapStoreImpl<Integer, String>(hashProvider, values[0]); | ||
42 | return (VersionedMapImpl<Integer, String>) store.createMap(); | ||
43 | } | ||
44 | |||
45 | public Integer nextKey() { | ||
46 | return random.nextInt(nKeys); | ||
47 | } | ||
48 | |||
49 | public boolean isDefault(String value) { | ||
50 | return value == values[0]; | ||
51 | } | ||
52 | |||
53 | public String nextValue() { | ||
54 | return values[random.nextInt(nValues)]; | ||
55 | } | ||
56 | } | ||