-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBenchParameters.java
More file actions
150 lines (121 loc) · 4.73 KB
/
BenchParameters.java
File metadata and controls
150 lines (121 loc) · 4.73 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package contention.benchmark.workload;
import contention.benchmark.json.serializers.DataMapBuilderSerializer;
import contention.benchmark.workload.data.map.abstractions.DataMapBuilder;
import contention.benchmark.workload.stop.condition.OperationCounter;
import contention.benchmark.workload.thread.loops.builders.PrefillInsertThreadLoopBuilder;
import static contention.benchmark.tools.StringFormat.getStringStage;
import static contention.benchmark.tools.StringFormat.indentedTitleWithData;
public class BenchParameters {
public int iterations = 1;
public int range = 2048;
public boolean detailedStats = false;
public long afterPrefillDuration = 1000;
public long afterWarmUpDuration = 0;
public long betweenIterationsDuration = 100;
public Parameters test;
public Parameters prefill;
public Parameters warmUp;
public BenchParameters() {
test = new Parameters();
createDefaultPrefill();
warmUp = new Parameters();
// without warmUp
warmUp.numThreads = 0;
}
public BenchParameters(Parameters test, Parameters prefill, Parameters warmUp) {
this.test = test;
this.prefill = prefill;
this.warmUp = warmUp;
}
public BenchParameters createDefaultPrefill(int threadNum) {
prefill = new Parameters()
.setStopCondition(new OperationCounter(range / 2))
.addThreadLoopBuilder(
new PrefillInsertThreadLoopBuilder(),
threadNum
);
return this;
}
public BenchParameters createDefaultPrefill() {
return createDefaultPrefill(1);
}
public BenchParameters setIterations(int iterations) {
this.iterations = iterations;
return this;
}
public BenchParameters setRange(int range) {
this.range = range;
return this;
}
public BenchParameters setDetailedStats(boolean detailedStats) {
this.detailedStats = detailedStats;
return this;
}
public BenchParameters enableDetailedStats() {
this.detailedStats = true;
return this;
}
public BenchParameters disableDetailedStats() {
this.detailedStats = false;
return this;
}
public BenchParameters setAfterPrefillDuration(long afterPrefillDuration) {
this.afterPrefillDuration = afterPrefillDuration;
return this;
}
public BenchParameters setAfterWarmUpDuration(long afterWarmUpDuration) {
this.afterWarmUpDuration = afterWarmUpDuration;
return this;
}
public BenchParameters setBetweenIterationsDuration(long betweenIterationsDuration) {
this.betweenIterationsDuration = betweenIterationsDuration;
return this;
}
public BenchParameters setTest(Parameters test) {
this.test = test;
return this;
}
public BenchParameters setPrefill(Parameters prefill) {
this.prefill = prefill;
return this;
}
public BenchParameters setWarmUp(Parameters warmUp) {
this.warmUp = warmUp;
return this;
}
public void init() {
for (DataMapBuilder currentBuilder : DataMapBuilderSerializer.getBuilders().values()) {
currentBuilder.init(range);
}
test.init(range);
prefill.init(range);
warmUp.init(range);
}
public StringBuilder toStringBuilder() {
return toStringBuilder(1);
}
public StringBuilder toStringBuilder(int indents) {
StringBuilder result = new StringBuilder()
.append(indentedTitleWithData("Range", range, indents))
.append(indentedTitleWithData("Iterations", iterations, indents))
.append(indentedTitleWithData("Detailed stats", this.detailedStats ? "enabled" : "disabled", indents))
.append(indentedTitleWithData("After prefill duration", afterPrefillDuration, indents))
.append(indentedTitleWithData("After warm up duration", afterWarmUpDuration, indents))
.append(indentedTitleWithData("Between iterations duration", betweenIterationsDuration, indents));
if (prefill.numThreads == 0) {
result.append(getStringStage("Without prefill"));
} else {
result.append(getStringStage("Prefill parameters"))
.append(prefill.toStringBuilder(indents));
}
if (warmUp.numThreads == 0) {
result.append(getStringStage("Without WarmUp"));
} else {
result.append(getStringStage("WarmUp parameters"))
.append(warmUp.toStringBuilder(indents));
}
result.append(getStringStage("Test parameters"))
.append(test.toStringBuilder(indents));
return result;
}
}