Skip to content

Commit 48e9df4

Browse files
committed
add normalized results
1 parent b3fde6e commit 48e9df4

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

test/benchmarks/driver_bench/src/driver.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export const PARALLEL_DIRECTORY = path.resolve(SPEC_DIRECTORY, 'parallel');
124124
export const TEMP_DIRECTORY = path.resolve(SPEC_DIRECTORY, 'tmp');
125125

126126
export type Metric = {
127-
name: 'megabytes_per_second';
127+
name: 'megabytes_per_second' | 'normalized_throughput';
128128
value: number;
129129
};
130130

test/benchmarks/driver_bench/src/main.mts

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ console.log(systemInfo());
8585

8686
const runnerPath = path.join(__dirname, 'runner.mjs');
8787

88-
const results: MetricInfo[] = [];
88+
let results: MetricInfo[] = [];
8989

9090
for (const [suite, benchmarks] of Object.entries(tests)) {
9191
console.group(snakeToCamel(suite));
@@ -146,8 +146,8 @@ function calculateCompositeBenchmarks(results: MetricInfo[]) {
146146

147147
const aMetricInfo =
148148
(testName: string) =>
149-
({ info: { test_name } }: MetricInfo) =>
150-
test_name === testName;
149+
({ info: { test_name } }: MetricInfo) =>
150+
test_name === testName;
151151

152152
const anMBsMetric = ({ name }: Metric) => name === 'megabytes_per_second';
153153

@@ -198,6 +198,32 @@ function calculateCompositeBenchmarks(results: MetricInfo[]) {
198198
return [...results, ...compositeResults];
199199
}
200200

201-
const finalResults = calculateCompositeBenchmarks(results);
201+
function calculateNormalizedResults(results: MetricInfo[]): MetricInfo[] {
202+
const primesBench = results.find(r => r.info.test_name === 'primes');
203+
const pingBench = results.find(r => r.info.test_name === 'ping');
204+
let pingMegabytesPerSecond: number;
202205

203-
await fs.writeFile('results.json', JSON.stringify(finalResults, undefined, 2), 'utf8');
206+
if (pingBench) {
207+
const pingThroughput = pingBench.metrics[0].value;
208+
for (const bench of results) {
209+
if (bench.info.test_name === 'primes' || bench.info.test_name === 'ping') continue;
210+
const normalizedThroughput = bench.metrics[0].value / pingThroughput;
211+
bench.metrics.push({name: 'normalized_throughput', value: normalizedThroughput});
212+
213+
}
214+
215+
if (primesBench) {
216+
const normalizedThroughput = pingBench.metrics[0].value / primesBench.metrics[0].value;
217+
pingMegabytesPerSecond = pingBench.metrics[0].value;
218+
pingBench.metrics.push({ name: 'normalized_throughput', value: normalizedThroughput });
219+
}
220+
}
221+
222+
return results;
223+
}
224+
225+
results = calculateNormalizedResults(results);
226+
results = calculateCompositeBenchmarks(results);
227+
228+
229+
await fs.writeFile('results.json', JSON.stringify(results, undefined, 2), 'utf8');

test/benchmarks/driver_bench/src/runner.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type BenchmarkModule = {
1414
run: () => Promise<void>;
1515
afterEach?: () => Promise<void>;
1616
after?: () => Promise<void>;
17+
tags?: string[];
1718
};
1819

1920
const benchmarkName = snakeToCamel(path.basename(benchmarkFile, '.mjs'));

0 commit comments

Comments
 (0)