diff options
author | Kristóf Marussy <marussy@mit.bme.hu> | 2021-09-29 02:45:57 +0200 |
---|---|---|
committer | Kristóf Marussy <marussy@mit.bme.hu> | 2021-09-29 03:16:01 +0200 |
commit | a155f6ba02e08a75ce6e474a86900b8363f506e8 (patch) | |
tree | b78804c1c0f0968a9625f0656e08f5dadc16924c /model-data/src/jmh/java/org/eclipse/viatra/solver/data/map/benchmarks/ImmutablePutBenchmark.java | |
parent | Simplify branding (diff) | |
download | refinery-a155f6ba02e08a75ce6e474a86900b8363f506e8.tar.gz refinery-a155f6ba02e08a75ce6e474a86900b8363f506e8.tar.zst refinery-a155f6ba02e08a75ce6e474a86900b8363f506e8.zip |
build: migration to Gradle 7
Diffstat (limited to 'model-data/src/jmh/java/org/eclipse/viatra/solver/data/map/benchmarks/ImmutablePutBenchmark.java')
-rw-r--r-- | model-data/src/jmh/java/org/eclipse/viatra/solver/data/map/benchmarks/ImmutablePutBenchmark.java | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/model-data/src/jmh/java/org/eclipse/viatra/solver/data/map/benchmarks/ImmutablePutBenchmark.java b/model-data/src/jmh/java/org/eclipse/viatra/solver/data/map/benchmarks/ImmutablePutBenchmark.java deleted file mode 100644 index f0af443f..00000000 --- a/model-data/src/jmh/java/org/eclipse/viatra/solver/data/map/benchmarks/ImmutablePutBenchmark.java +++ /dev/null | |||
@@ -1,77 +0,0 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.benchmarks; | ||
2 | |||
3 | import java.util.ArrayList; | ||
4 | import java.util.HashMap; | ||
5 | import java.util.concurrent.TimeUnit; | ||
6 | |||
7 | import org.openjdk.jmh.annotations.Benchmark; | ||
8 | import org.openjdk.jmh.annotations.BenchmarkMode; | ||
9 | import org.openjdk.jmh.annotations.Fork; | ||
10 | import org.openjdk.jmh.annotations.Measurement; | ||
11 | import org.openjdk.jmh.annotations.Mode; | ||
12 | import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
13 | import org.openjdk.jmh.annotations.Warmup; | ||
14 | import org.openjdk.jmh.infra.Blackhole; | ||
15 | |||
16 | @Fork(1) | ||
17 | @BenchmarkMode(Mode.AverageTime) | ||
18 | @OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
19 | @Measurement(time = 1, timeUnit = TimeUnit.SECONDS) | ||
20 | @Warmup(time = 1, timeUnit = TimeUnit.SECONDS) | ||
21 | public class ImmutablePutBenchmark { | ||
22 | @Benchmark | ||
23 | public void immutablePutBenchmark(ImmutablePutExecutionPlan executionPlan, Blackhole blackhole) { | ||
24 | var sut = executionPlan.createSut(); | ||
25 | for (int i = 0; i < executionPlan.nPut; i++) { | ||
26 | sut.put(executionPlan.nextKey(), executionPlan.nextValue()); | ||
27 | } | ||
28 | blackhole.consume(sut); | ||
29 | } | ||
30 | |||
31 | @Benchmark | ||
32 | public void immutablePutAndCommitBenchmark(ImmutablePutExecutionPlan executionPlan, Blackhole blackhole) { | ||
33 | var sut = executionPlan.createSut(); | ||
34 | for (int i = 0; i < executionPlan.nPut; i++) { | ||
35 | sut.put(executionPlan.nextKey(), executionPlan.nextValue()); | ||
36 | if (i % 10 == 0) { | ||
37 | blackhole.consume(sut.commit()); | ||
38 | } | ||
39 | } | ||
40 | blackhole.consume(sut); | ||
41 | } | ||
42 | |||
43 | @Benchmark | ||
44 | public void baselinePutBenchmark(ImmutablePutExecutionPlan executionPlan, Blackhole blackhole) { | ||
45 | var sut = new HashMap<Integer, String>(); | ||
46 | for (int i = 0; i < executionPlan.nPut; i++) { | ||
47 | var key = executionPlan.nextKey(); | ||
48 | var value = executionPlan.nextValue(); | ||
49 | if (executionPlan.isDefault(value)) { | ||
50 | sut.remove(key); | ||
51 | } else { | ||
52 | sut.put(key, value); | ||
53 | } | ||
54 | } | ||
55 | blackhole.consume(sut); | ||
56 | } | ||
57 | |||
58 | @Benchmark | ||
59 | public void baselinePutAndCommitBenchmark(ImmutablePutExecutionPlan executionPlan, Blackhole blackhole) { | ||
60 | var sut = new HashMap<Integer, String>(); | ||
61 | var store = new ArrayList<HashMap<Integer, String>>(); | ||
62 | for (int i = 0; i < executionPlan.nPut; i++) { | ||
63 | var key = executionPlan.nextKey(); | ||
64 | var value = executionPlan.nextValue(); | ||
65 | if (executionPlan.isDefault(value)) { | ||
66 | sut.remove(key); | ||
67 | } else { | ||
68 | sut.put(key, value); | ||
69 | } | ||
70 | if (i % 10 == 0) { | ||
71 | store.add(new HashMap<>(sut)); | ||
72 | } | ||
73 | } | ||
74 | blackhole.consume(sut); | ||
75 | blackhole.consume(store); | ||
76 | } | ||
77 | } | ||