perfshield 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/runner.js +21 -2
- package/package.json +1 -1
package/lib/runner.js
CHANGED
|
@@ -12,6 +12,23 @@ const getVersionOrder = seed => {
|
|
|
12
12
|
}
|
|
13
13
|
return [versions[1], versions[0]];
|
|
14
14
|
};
|
|
15
|
+
const buildIndexOrder = (count, seed) => {
|
|
16
|
+
const order = Array.from({
|
|
17
|
+
length: count
|
|
18
|
+
}, (_, index) => index);
|
|
19
|
+
if (count <= 1) {
|
|
20
|
+
return order;
|
|
21
|
+
}
|
|
22
|
+
let state = seed >>> 0;
|
|
23
|
+
for (let i = count - 1; i > 0; i -= 1) {
|
|
24
|
+
state = state * 1_664_525 + 1_013_904_223 >>> 0;
|
|
25
|
+
const j = state % (i + 1);
|
|
26
|
+
const swap = order[i];
|
|
27
|
+
order[i] = order[j];
|
|
28
|
+
order[j] = swap;
|
|
29
|
+
}
|
|
30
|
+
return order;
|
|
31
|
+
};
|
|
15
32
|
const sleep = async delayMs => {
|
|
16
33
|
if (delayMs <= 0) {
|
|
17
34
|
return;
|
|
@@ -130,7 +147,8 @@ const collectSamples = async (harness, benchmarks, minSamples, iterationOverride
|
|
|
130
147
|
const total = minSamples * benchmarks.length;
|
|
131
148
|
for (let iteration = 0; iteration < minSamples; iteration += 1) {
|
|
132
149
|
const order = getVersionOrder(iteration);
|
|
133
|
-
|
|
150
|
+
const indexOrder = buildIndexOrder(benchmarks.length, iteration);
|
|
151
|
+
for (const index of indexOrder) {
|
|
134
152
|
const iterations = iterationOverrides[index];
|
|
135
153
|
const minimumIterations = benchmarks[index].iterations ?? 1;
|
|
136
154
|
const result = await runSamplePair(harness, index, iterations, order);
|
|
@@ -181,8 +199,9 @@ const autoSample = async (harness, benchmarks, samples, conditions, maxRelativeM
|
|
|
181
199
|
}
|
|
182
200
|
for (let batch = 0; batch < autoSampleBatchSize; batch += 1) {
|
|
183
201
|
const order = getVersionOrder(roundRobinSeed);
|
|
202
|
+
const indexOrder = buildIndexOrder(benchmarks.length, roundRobinSeed);
|
|
184
203
|
roundRobinSeed += 1;
|
|
185
|
-
for (
|
|
204
|
+
for (const index of indexOrder) {
|
|
186
205
|
const iterations = iterationOverrides[index];
|
|
187
206
|
const minimumIterations = benchmarks[index].iterations ?? 1;
|
|
188
207
|
const result = await runSamplePair(harness, index, iterations, order);
|