Skip to content

Commit e252536

Browse files
committed
address review comments
1 parent f267fd0 commit e252536

20 files changed

+66
-61
lines changed

test/benchmarks/driver_bench/src/driver.mts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@ import process from 'node:process';
77
const __dirname = import.meta.dirname;
88
const require = module.createRequire(__dirname);
99

10-
// Special tag that marks a benchmark as a spec-required benchmark
11-
export const SPEC_TAG = 'spec-benchmark';
12-
// Special tag that enables our perf monitoring tooling to create alerts when regressions in this
13-
// benchmark's performance are detected
14-
export const ALERT_TAG = 'alerting-benchmark';
15-
// Tag marking a benchmark as being related to cursor performance
16-
export const CURSOR_TAG = 'cursor-benchmark';
17-
// Tag marking a benchmark as being related to read performance
18-
export const READ_TAG = 'read-benchmark';
19-
// Tag marking a benchmark as being related to write performance
20-
export const WRITE_TAG = 'write-benchmark';
10+
export const TAG = {
11+
// Special tag that marks a benchmark as a spec-required benchmark
12+
spec: 'spec-benchmark',
13+
// Special tag that enables our perf monitoring tooling to create alerts when regressions in this
14+
// benchmark's performance are detected
15+
alert: 'alerting-benchmark',
16+
// Tag marking a benchmark as being related to cursor performance
17+
cursor: 'cursor-benchmark',
18+
// Tag marking a benchmark as being related to read performance
19+
read: 'read-benchmark',
20+
// Tag marking a benchmark as being related to write performance
21+
write: 'write-benchmark'
22+
};
2123

24+
// Constant used to scale normalized_throughput results for ping benchmark to be roughly in the
25+
// range 0 - 9 to make it easier to work with
2226
export const NORMALIZED_PING_SCALING_CONST = 1000;
2327

2428
/**

test/benchmarks/driver_bench/src/main.mts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -203,22 +203,16 @@ function calculateNormalizedResults(results: MetricInfo[]): MetricInfo[] {
203203
const primesBench = results.find(r => r.info.test_name === 'primes');
204204
const pingBench = results.find(r => r.info.test_name === 'ping');
205205

206-
if (pingBench) {
207-
const pingThroughput = pingBench.metrics[0].value;
208-
for (const bench of results) {
209-
if (bench.info.test_name === 'ping') {
210-
// Compute ping's normalized_throughput against the primes bench if present
211-
if (primesBench) {
212-
const primesThroughput = primesBench.metrics[0].value;
213-
const normalizedThroughput: Metric = { 'name': 'normalized_throughput', value: NORMALIZED_PING_SCALING_CONST * bench.metrics[0].value / primesThroughput };
214-
bench.metrics.push(normalizedThroughput);
215-
}
216-
} else {
217-
// Compute normalized_throughput of benchmarks against ping bench
218-
const normalizedThroughput: Metric = { 'name': 'normalized_throughput', value: bench.metrics[0].value / pingThroughput };
219-
bench.metrics.push(normalizedThroughput);
220-
}
221-
}
206+
assert.ok(pingBench);
207+
assert.ok(primesBench);
208+
const pingThroughput = pingBench.metrics[0].value;
209+
const primesThroughput = primesBench.metrics[0].value;
210+
primesBench.metrics.push({ 'name': 'normalized_throughput', value: NORMALIZED_PING_SCALING_CONST * pingThroughput / primesThroughput });
211+
212+
for (const bench of results) {
213+
if (bench.info.test_name === 'ping' || bench.info.test_name === 'primes') continue;
214+
// Compute normalized_throughput of benchmarks against ping bench
215+
bench.metrics.push({ 'name': 'normalized_throughput', value: bench.metrics[0].value / pingThroughput });
222216
}
223217

224218
return results;

test/benchmarks/driver_bench/src/runner.mts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ function percentileIndex(percentile: number, count: number) {
8181

8282
const medianExecution = durations[percentileIndex(50, count)];
8383
const megabytesPerSecond = benchmark.taskSize / medianExecution;
84+
8485
const tags = benchmark.tags;
86+
if (tags &&
87+
(!Array.isArray(tags) || (tags.length > 0 && !tags.every(t => typeof t === 'string')))) {
88+
89+
throw new Error('If tags is specified, it MUST be an array of strings');
90+
}
8591

8692
console.log(
8793
' '.repeat(3),

test/benchmarks/driver_bench/src/suites/multi_bench/find_many_and_empty_cursor.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* eslint-disable @typescript-eslint/no-unused-vars */
2-
import { driver, ALERT_TAG, SPEC_TAG, type mongodb, CURSOR_TAG, READ_TAG } from '../../driver.mjs';
2+
import { driver, TAG, type mongodb, CURSOR_TAG, READ_TAG } from '../../driver.mjs';
33

44
export const taskSize = 16.22;
55

6-
export const tags = [ALERT_TAG, SPEC_TAG, CURSOR_TAG, READ_TAG];
6+
export const tags = [TAG.alert, TAG.spec, TAG.cursor, TAG.read];
77

88
let collection: mongodb.Collection;
99

test/benchmarks/driver_bench/src/suites/multi_bench/grid_fs_download.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Readable, Writable } from 'node:stream';
22
import { pipeline } from 'node:stream/promises';
33

4-
import { driver, SPEC_TAG, ALERT_TAG, type mongodb, CURSOR_TAG, READ_TAG } from '../../driver.mjs';
4+
import { driver, type mongodb, TAG } from '../../driver.mjs';
55

66
export const taskSize = 52.43;
77

8-
export const tags = [ALERT_TAG, SPEC_TAG, CURSOR_TAG, READ_TAG];
8+
export const tags = [TAG.alert, TAG.spec, TAG.cursor, TAG.read];
99

1010
let bucket: mongodb.GridFSBucket;
1111
let bin: Uint8Array;

test/benchmarks/driver_bench/src/suites/multi_bench/grid_fs_upload.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Readable } from 'node:stream';
22
import { pipeline } from 'node:stream/promises';
33

4-
import { ALERT_TAG, driver, SPEC_TAG, WRITE_TAG, type mongodb } from '../../driver.mjs';
4+
import { driver, TAG, type mongodb } from '../../driver.mjs';
55

66
export const taskSize = 52.43;
7-
export const tags = [ALERT_TAG, SPEC_TAG, WRITE_TAG];
7+
export const tags = [TAG.alert, TAG.spec, TAG.write];
88

99
let bucket: mongodb.GridFSBucket;
1010
let uploadStream: mongodb.GridFSBucketWriteStream;

test/benchmarks/driver_bench/src/suites/multi_bench/large_doc_bulk_insert.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { ALERT_TAG, driver, SPEC_TAG, WRITE_TAG, type mongodb } from '../../driver.mjs';
1+
import { driver, TAG, type mongodb } from '../../driver.mjs';
22

33
export const taskSize = 27.31;
4-
export const tags = [SPEC_TAG, ALERT_TAG, WRITE_TAG];
4+
export const tags = [TAG.alert, TAG.spec, TAG.write];
55

66
let collection: mongodb.Collection;
77
let documents: any[];

test/benchmarks/driver_bench/src/suites/multi_bench/small_doc_bulk_insert.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { ALERT_TAG, driver, SPEC_TAG, WRITE_TAG, type mongodb } from '../../driver.mjs';
1+
import { TAG, driver, type mongodb } from '../../driver.mjs';
22

33
export const taskSize = 2.75;
4-
export const tags = [SPEC_TAG, ALERT_TAG, WRITE_TAG];
4+
export const tags = [TAG.alert, TAG.spec, TAG.write];
55

66
let collection: mongodb.Collection;
77
let documents: any[];

test/benchmarks/driver_bench/src/suites/node_specific/aggregate_a_million_documents_and_to_array.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { ALERT_TAG, CURSOR_TAG, driver, READ_TAG, type mongodb } from '../../driver.mjs';
1+
import { driver, TAG, type mongodb } from '../../driver.mjs';
22

33
export const taskSize = 16;
4-
export const tags = [ALERT_TAG, CURSOR_TAG, READ_TAG];
4+
export const tags = [TAG.alert, TAG.cursor, TAG.read];
55

66
let db: mongodb.Db;
77

test/benchmarks/driver_bench/src/suites/node_specific/aggregate_a_million_tweets_and_to_array.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { ALERT_TAG, driver, READ_TAG, type mongodb } from '../../driver.mjs';
1+
import {driver, TAG, type mongodb } from '../../driver.mjs';
22

33
export const taskSize = 1500;
4-
export const tags = [ALERT_TAG, CURSOR_TAG, READ_TAG];
4+
export const tags = [TAG.alert, TAG.cursor, TAG.read];
55

66
let db: mongodb.Db;
77
let tweet: Record<string, any>;

0 commit comments

Comments
 (0)