Skip to content

Commit d1f1014

Browse files
committed
add tags to granular benchmarks
1 parent 239a153 commit d1f1014

17 files changed

+126
-49
lines changed

test/bench/granular/binary.bench.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ import {
55
BOOL,
66
ITERATIONS,
77
LIBRARY_SPEC,
8-
WARMUP
8+
WARMUP,
9+
getTags
910
} from './common';
1011

1112
async function main() {
1213
const suite = new Suite('Binary');
1314
const testDocs = await getTestDocs('binary');
1415
// deserialize
1516
for (const documentPath of testDocs) {
17+
const tags = getTags(documentPath);
1618
for (const promoteBuffers of BOOL) {
1719
suite.task({
1820
documentPath,
@@ -22,7 +24,8 @@ async function main() {
2224
operation: 'deserialize',
2325
options: {
2426
promoteBuffers
25-
}
27+
},
28+
tags
2629
});
2730
}
2831

@@ -33,7 +36,8 @@ async function main() {
3336
iterations: ITERATIONS,
3437
warmup: WARMUP,
3538
operation: 'serialize',
36-
options: { checkKeys: true, ignoreUndefined: false }
39+
options: { checkKeys: true, ignoreUndefined: false },
40+
tags
3741
});
3842
}
3943
await runSuiteAndWriteResults(suite);

test/bench/granular/boolean.bench.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
BOOL,
66
ITERATIONS,
77
WARMUP,
8-
LIBRARY_SPEC
8+
LIBRARY_SPEC,
9+
getTags
910
} from './common';
1011

1112
const OPTIONS = {
@@ -21,27 +22,31 @@ async function main() {
2122
const testDocs = await getTestDocs('boolean');
2223
// deserialize
2324
for (const documentPath of testDocs) {
25+
const tags = getTags(documentPath);
2426
for (const promoteValues of BOOL) {
2527
suite.task({
2628
documentPath,
2729
library: LIBRARY_SPEC,
2830
iterations: ITERATIONS,
2931
warmup: WARMUP,
3032
operation: 'deserialize',
31-
options: { ...OPTIONS.deserialize, promoteValues }
33+
options: { ...OPTIONS.deserialize, promoteValues },
34+
tags
3235
});
3336
}
3437
}
3538

3639
// serialize
3740
for (const documentPath of testDocs) {
41+
const tags = getTags(documentPath);
3842
suite.task({
3943
documentPath,
4044
library: LIBRARY_SPEC,
4145
iterations: ITERATIONS,
4246
warmup: WARMUP,
4347
operation: 'deserialize',
44-
options: OPTIONS.serialize
48+
options: OPTIONS.serialize,
49+
tags
4550
});
4651
}
4752
await runSuiteAndWriteResults(suite);

test/bench/granular/code.bench.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
OPERATIONS,
66
ITERATIONS,
77
LIBRARY_SPEC,
8-
WARMUP
8+
WARMUP,
9+
getTags
910
} from './common';
1011

1112
const OPTIONS = {
@@ -19,15 +20,17 @@ async function main() {
1920
await getTestDocs('code-with-scope')
2021
);
2122

22-
for (const operation of OPERATIONS) {
23-
for (const documentPath of testDocs) {
23+
for (const documentPath of testDocs) {
24+
const tags = getTags(documentPath);
25+
for (const operation of OPERATIONS) {
2426
suite.task({
2527
documentPath,
2628
library: LIBRARY_SPEC,
2729
iterations: ITERATIONS,
2830
warmup: WARMUP,
2931
operation,
30-
options: OPTIONS[operation]
32+
options: OPTIONS[operation],
33+
tags
3134
});
3235
}
3336
}

test/bench/granular/common.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,29 @@ export async function getTestDocs(type: string) {
2525
return docs;
2626
}
2727

28+
const ALERTING_DOCS = new Set([
29+
'objectid_array_1000',
30+
'double_array_1000',
31+
'int32_array_1000',
32+
'long_array_1000',
33+
'string_array_1000',
34+
'binary_array_1000'
35+
]);
36+
37+
export const ALERT_TAG = 'alerting-benchmark';
38+
39+
export function getTags(documentPath: string) {
40+
const stem = path.basename(documentPath).split('.')[0];
41+
const type = stem.split('_')[0];
42+
43+
if (ALERTING_DOCS.has(stem)) {
44+
return [type, ALERT_TAG];
45+
} else {
46+
return [type];
47+
}
48+
}
49+
50+
2851
export async function runSuiteAndWriteResults(suite: Suite) {
2952
const targetDirectory = path.resolve(`${__dirname}/../../etc`);
3053
await suite.run();
@@ -48,6 +71,7 @@ export function readEnvVars(): { warmup: number; iterations: number; library: st
4871
return rv;
4972
}
5073

74+
5175
const envVars = readEnvVars();
5276
export const ITERATIONS = envVars.iterations;
5377
export const WARMUP = envVars.warmup;

test/bench/granular/date.bench.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
OPERATIONS,
66
ITERATIONS,
77
LIBRARY_SPEC,
8-
WARMUP
8+
WARMUP,
9+
getTags
910
} from './common';
1011

1112
const OPTIONS = {
@@ -17,15 +18,17 @@ async function main() {
1718
const suite = new Suite('Date');
1819
const testDocs = await getTestDocs('date');
1920

20-
for (const operation of OPERATIONS) {
21-
for (const documentPath of testDocs) {
21+
for (const documentPath of testDocs) {
22+
const tags = getTags(documentPath);
23+
for (const operation of OPERATIONS) {
2224
suite.task({
2325
documentPath,
2426
library: LIBRARY_SPEC,
2527
iterations: ITERATIONS,
2628
warmup: WARMUP,
2729
operation,
28-
options: OPTIONS[operation]
30+
options: OPTIONS[operation],
31+
tags
2932
});
3033
}
3134
}

test/bench/granular/decimal128.bench.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
OPERATIONS,
66
ITERATIONS,
77
LIBRARY_SPEC,
8-
WARMUP
8+
WARMUP,
9+
getTags
910
} from './common';
1011

1112
const OPTIONS = {
@@ -21,15 +22,17 @@ const OPTIONS = {
2122
async function main() {
2223
const suite = new Suite('Decimal128');
2324
const testDocs = await getTestDocs('decimal128');
24-
for (const operation of OPERATIONS) {
25-
for (const documentPath of testDocs) {
25+
for (const documentPath of testDocs) {
26+
const tags = getTags(documentPath);
27+
for (const operation of OPERATIONS) {
2628
suite.task({
2729
documentPath,
2830
library: LIBRARY_SPEC,
2931
iterations: ITERATIONS,
3032
warmup: WARMUP,
3133
operation,
32-
options: OPTIONS[operation]
34+
options: OPTIONS[operation],
35+
tags
3336
});
3437
}
3538
}

test/bench/granular/double.bench.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
LIBRARY_SPEC,
66
BOOL,
77
ITERATIONS,
8-
WARMUP
8+
WARMUP,
9+
getTags
910
} from './common';
1011

1112
const OPTIONS = {
@@ -20,6 +21,7 @@ async function main() {
2021
const testDocs = await getTestDocs('double');
2122

2223
for (const documentPath of testDocs) {
24+
const tags = getTags(documentPath);
2325
// deserialize
2426
for (const promoteValues of BOOL) {
2527
suite.task({
@@ -28,7 +30,8 @@ async function main() {
2830
iterations: ITERATIONS,
2931
warmup: WARMUP,
3032
operation: 'deserialize',
31-
options: { ...OPTIONS.deserialize, promoteValues }
33+
options: { ...OPTIONS.deserialize, promoteValues },
34+
tags
3235
});
3336
}
3437

@@ -39,7 +42,8 @@ async function main() {
3942
iterations: ITERATIONS,
4043
warmup: WARMUP,
4144
operation: 'serialize',
42-
options: OPTIONS.serialize
45+
options: OPTIONS.serialize,
46+
tags
4347
});
4448
}
4549
await runSuiteAndWriteResults(suite);

test/bench/granular/int32.bench.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ async function main() {
2323
const suite = new Suite('Int32');
2424
const testDocs = await getTestDocs('int32');
2525
for (const documentPath of testDocs) {
26+
const tags = getTags(documentPath);
2627
// deserialize
2728
for (const promoteValues of BOOL) {
2829
suite.task({
@@ -31,7 +32,8 @@ async function main() {
3132
iterations: ITERATIONS,
3233
warmup: WARMUP,
3334
operation: 'deserialize',
34-
options: { ...OPTIONS.deserialize, promoteValues }
35+
options: { ...OPTIONS.deserialize, promoteValues },
36+
tags
3537
});
3638
}
3739
//serialize
@@ -41,7 +43,8 @@ async function main() {
4143
iterations: ITERATIONS,
4244
warmup: WARMUP,
4345
operation: 'serialize',
44-
options: OPTIONS.serialize
46+
options: OPTIONS.serialize,
47+
tags
4548
});
4649
}
4750
await runSuiteAndWriteResults(suite);

test/bench/granular/long.bench.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Suite } from 'dbx-js-tools/packages/bson-bench';
2-
import { getTestDocs, runSuiteAndWriteResults, ITERATIONS, LIBRARY_SPEC, WARMUP } from './common';
2+
import { getTestDocs, runSuiteAndWriteResults, ITERATIONS, LIBRARY_SPEC, WARMUP, getTags } from './common';
33

44
const JSBSONDeserializationOptions = [
55
{
@@ -29,28 +29,32 @@ async function main() {
2929
const testDocs = await getTestDocs('long');
3030
// LONG JS-BSON Deserialization tests
3131
for (const documentPath of testDocs) {
32+
const tags = getTags(documentPath);
3233
for (const options of JSBSONDeserializationOptions) {
3334
suite.task({
3435
documentPath,
3536
library: LIBRARY_SPEC,
3637
iterations: ITERATIONS,
3738
warmup: WARMUP,
3839
operation: 'deserialize',
39-
options
40+
options,
41+
tags
4042
});
4143
}
4244
}
4345

4446
// LONG JS-BSON Serialization tests
4547
for (const documentPath of testDocs) {
48+
const tags = getTags(documentPath);
4649
for (const options of JSBSONSerializationOptions) {
4750
suite.task({
4851
documentPath,
4952
library: LIBRARY_SPEC,
5053
iterations: ITERATIONS,
5154
warmup: WARMUP,
5255
operation: 'serialize',
53-
options
56+
options,
57+
tags
5458
});
5559
}
5660
}

test/bench/granular/maxkey.bench.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
LIBRARY_SPEC,
66
OPERATIONS,
77
ITERATIONS,
8-
WARMUP
8+
WARMUP,
9+
getTags
910
} from './common';
1011

1112
const OPTIONS = {
@@ -19,15 +20,17 @@ async function main() {
1920
const suite = new Suite('MaxKey');
2021
const testDocs = await getTestDocs('maxkey');
2122

22-
for (const operation of OPERATIONS) {
23-
for (const documentPath of testDocs) {
23+
for (const documentPath of testDocs) {
24+
const tags = getTags(documentPath);
25+
for (const operation of OPERATIONS) {
2426
suite.task({
2527
documentPath,
2628
library: LIBRARY_SPEC,
2729
iterations: ITERATIONS,
2830
warmup: WARMUP,
2931
operation,
30-
options: OPTIONS[operation]
32+
options: OPTIONS[operation],
33+
tags
3134
});
3235
}
3336
}

test/bench/granular/minkey.bench.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
LIBRARY_SPEC,
66
OPERATIONS,
77
ITERATIONS,
8-
WARMUP
8+
WARMUP,
9+
getTags
910
} from './common';
1011

1112
const OPTIONS = {
@@ -21,13 +22,15 @@ async function main() {
2122

2223
for (const operation of OPERATIONS) {
2324
for (const documentPath of testDocs) {
25+
const tags = getTags(documentPath);
2426
suite.task({
2527
documentPath,
2628
library: LIBRARY_SPEC,
2729
iterations: ITERATIONS,
2830
warmup: WARMUP,
2931
operation,
30-
options: OPTIONS[operation]
32+
options: OPTIONS[operation],
33+
tags
3134
});
3235
}
3336
}

test/bench/granular/mixed.bench.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ async function main() {
3131

3232
const suite = new Suite('Mixed Documents');
3333

34+
// TODO:
3435
for (const operation of OPERATIONS) {
3536
for (const documentPath of mixedDocuments) {
3637
suite.task({

0 commit comments

Comments
 (0)