This repository was archived by the owner on Mar 4, 2025. It is now read-only.
forked from iguana-parser/iguana
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBenchmarkSettings.java
More file actions
121 lines (99 loc) · 3.85 KB
/
BenchmarkSettings.java
File metadata and controls
121 lines (99 loc) · 3.85 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package benchmark;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.ParseException;
import java.util.Properties;
public class BenchmarkSettings {
public static BenchmarkSettings parseCli(CommandLine cmd) throws ParseException {
Properties scenarioProperties = cmd.getOptionProperties(CliParser.SCENARIO_OPT);
return new BenchmarkSettings(
GraphStorage.valueOf(cmd.getOptionValue(CliParser.GRAPH_STORAGE_OPT)),
Problem.valueOf(cmd.getOptionValue(CliParser.PROBLEM_OPT)),
new ScenarioSettings(
Scenario.valueOf(scenarioProperties.getProperty(CliParser.SCENARIO_TYPE_PROP)),
scenarioProperties.getProperty(CliParser.SCENARIO_ARG_PROP)),
cmd.getOptionValue(CliParser.GRAMMAR_OPT),
cmd.getOptionValue(CliParser.GRAPH_OPT),
cmd.getOptionValue(CliParser.DATASET_OPT),
Integer.parseInt(cmd.getOptionValue(CliParser.WARMUP_ITERATIONS_OPT)),
Integer.parseInt(cmd.getOptionValue(CliParser.MEASUREMENT_ITERATIONS_OPT)),
cmd.hasOption(CliParser.MEMORY_USAGE));
}
private final GraphStorage storageType;
private final Problem problem;
private final ScenarioSettings scenario;
private final String datasetName;
private final String grammarPath;
private final String graphPath;
private final int warmupIterations;
private final int measurementIterations;
private final boolean withMemoryUsage;
private BenchmarkSettings(GraphStorage storageType,
Problem problem,
ScenarioSettings scenario,
String grammarPath,
String graphPath,
String datasetName,
int warmupIterations,
int measurementIterations,
boolean withMemoryUsage) {
this.storageType = storageType;
this.problem = problem;
this.scenario = scenario;
this.datasetName = datasetName;
this.grammarPath = grammarPath;
this.graphPath = graphPath;
this.warmupIterations = warmupIterations;
this.measurementIterations = measurementIterations;
this.withMemoryUsage = withMemoryUsage;
}
public GraphStorage getStorageType() {
return storageType;
}
public Problem getProblem() {
return problem;
}
public ScenarioSettings getScenario() {
return scenario;
}
public String getDatasetName() {
return datasetName;
}
public String getGrammarPath() {
return grammarPath;
}
public String getGraphPath() {
return graphPath;
}
public int getWarmupIterations() {
return warmupIterations;
}
public int getMeasurementIterations() {
return measurementIterations;
}
public boolean isWithMemoryUsage() { return withMemoryUsage; }
public static class ScenarioSettings {
private final Scenario scenario;
private final int nodesCount;
private final String path;
public ScenarioSettings(Scenario scenario, String optionArgument) {
this.scenario = scenario;
this.path = switch (scenario) {
case ALL_PAIRS -> null;
case MULTIPLE_SOURCES -> optionArgument;
};
this.nodesCount = switch (scenario) {
case ALL_PAIRS -> Integer.parseInt(optionArgument);
case MULTIPLE_SOURCES -> 0;
};
}
public Scenario getScenario() {
return scenario;
}
public int getNodesCount() {
return nodesCount;
}
public String getPath() {
return path;
}
}
}