-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCopyPropertiesBenchmark.java
More file actions
68 lines (59 loc) · 1.91 KB
/
CopyPropertiesBenchmark.java
File metadata and controls
68 lines (59 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package internal.tests.benchmarks;
import internal.tests.api.PropertiesCopier;
import internal.tests.common.TestPropsData;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;
import java.math.BigDecimal;
import java.util.concurrent.TimeUnit;
@State(Scope.Benchmark)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@BenchmarkMode({Mode.Throughput})
@Warmup(iterations = 3, time = 3, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 3, time = 3, timeUnit = TimeUnit.SECONDS)
@Fork(3)
public class CopyPropertiesBenchmark {
@Param({
"fs",
"apache",
"hutool",
//"direct"
})
private String copierType;
private PropertiesCopier copier;
private final TestPropsData data = new TestPropsData();
{
data.setI1(1);
data.setL1(2L);
data.setStr1("hello");
data.setIi1(3);
data.setLl1(4L);
data.setBb1(new BigDecimal("5.0"));
data.setI2(1);
data.setL2(2L);
data.setStr2("hello");
data.setIi2(3);
data.setLl2(4L);
data.setBb2(new BigDecimal("5.0"));
}
@Setup(Level.Trial)
public void setup() {
this.copier = PropertiesCopier.createCopier(copierType);
}
@Benchmark
public void copyProperties(Blackhole blackhole) throws Exception {
TestPropsData copy = new TestPropsData();
copier.copyProperties(data, copy);
blackhole.consume(copy);
}
}