-
Notifications
You must be signed in to change notification settings - Fork 621
Expand file tree
/
Copy pathBenchmarkRunner.java
More file actions
69 lines (58 loc) · 2.45 KB
/
BenchmarkRunner.java
File metadata and controls
69 lines (58 loc) · 2.45 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
69
package com.clickhouse.benchmark;
import com.clickhouse.benchmark.clients.InsertClient;
import com.clickhouse.benchmark.clients.QueryClient;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.profile.GCProfiler;
import org.openjdk.jmh.profile.MemPoolProfiler;
import org.openjdk.jmh.results.format.ResultFormatType;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openjdk.jmh.runner.options.TimeValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
public class BenchmarkRunner {
private static final Logger LOGGER = LoggerFactory.getLogger(BenchmarkRunner.class);
public static void main(String[] args) throws Exception {
LOGGER.info("Starting Benchmarks");
Map<String, String> argMap = parseArguments(args);
Options opt = new OptionsBuilder()
.param("datasetSourceName", argMap.getOrDefault("dataset", "simple"))
.include(QueryClient.class.getSimpleName())
.include(InsertClient.class.getSimpleName())
.forks(0) // must be a fork. No fork only for debugging
.mode(Mode.AverageTime)
.timeUnit(TimeUnit.MILLISECONDS)
.threads(1)
.addProfiler(GCProfiler.class)
.addProfiler(MemPoolProfiler.class)
.warmupIterations(1)
.warmupTime(TimeValue.seconds(10))
.measurementIterations(10)
.jvmArgs("-Xms6g", "-Xmx6g")
.measurementTime(TimeValue.seconds(10))
.resultFormat(ResultFormatType.JSON)
.result("jmh-simple-results.json")
.build();
new Runner(opt).run();
}
public static Map<String, String> parseArguments(String[] args) {
Map<String, String> argMap = new HashMap<>();
for (String arg : args) {
if (arg.startsWith("-")) {
String[] parts = arg.substring(2).split("=", 2);
if (parts.length == 2) {
String key = parts[0];
String value = parts[1];
if (key.equals("dataset") || key.equals("iterations")) {
argMap.put(key, value);
}
}
}
}
return argMap;
}
}