Skip to content

Commit 56f70bd

Browse files
committed
add tags to granular and spec tests
1 parent d1f1014 commit 56f70bd

18 files changed

+97
-69
lines changed

test/bench/granular/binary.bench.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import {
66
ITERATIONS,
77
LIBRARY_SPEC,
88
WARMUP,
9-
getTags
9+
getTypeTestTags
1010
} from './common';
1111

1212
async function main() {
1313
const suite = new Suite('Binary');
1414
const testDocs = await getTestDocs('binary');
1515
// deserialize
1616
for (const documentPath of testDocs) {
17-
const tags = getTags(documentPath);
17+
const tags = getTypeTestTags(documentPath);
1818
for (const promoteBuffers of BOOL) {
1919
suite.task({
2020
documentPath,

test/bench/granular/boolean.bench.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
ITERATIONS,
77
WARMUP,
88
LIBRARY_SPEC,
9-
getTags
9+
getTypeTestTags
1010
} from './common';
1111

1212
const OPTIONS = {
@@ -22,7 +22,7 @@ async function main() {
2222
const testDocs = await getTestDocs('boolean');
2323
// deserialize
2424
for (const documentPath of testDocs) {
25-
const tags = getTags(documentPath);
25+
const tags = getTypeTestTags(documentPath);
2626
for (const promoteValues of BOOL) {
2727
suite.task({
2828
documentPath,
@@ -38,7 +38,7 @@ async function main() {
3838

3939
// serialize
4040
for (const documentPath of testDocs) {
41-
const tags = getTags(documentPath);
41+
const tags = getTypeTestTags(documentPath);
4242
suite.task({
4343
documentPath,
4444
library: LIBRARY_SPEC,

test/bench/granular/code.bench.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
ITERATIONS,
77
LIBRARY_SPEC,
88
WARMUP,
9-
getTags
9+
getTypeTestTags
1010
} from './common';
1111

1212
const OPTIONS = {
@@ -21,7 +21,7 @@ async function main() {
2121
);
2222

2323
for (const documentPath of testDocs) {
24-
const tags = getTags(documentPath);
24+
const tags = getTypeTestTags(documentPath);
2525
for (const operation of OPERATIONS) {
2626
suite.task({
2727
documentPath,

test/bench/granular/common.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,38 @@ export async function getTestDocs(type: string) {
2626
}
2727

2828
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'
29+
'objectid_array_1000.json',
30+
'double_array_1000.json',
31+
'int32_array_1000.json',
32+
'long_array_1000.json',
33+
'string_array_1000.json',
34+
'binary_array_1000.json',
35+
'bestbuy_medium.json'
3536
]);
3637

3738
export const ALERT_TAG = 'alerting-benchmark';
3839

39-
export function getTags(documentPath: string) {
40-
const stem = path.basename(documentPath).split('.')[0];
41-
const type = stem.split('_')[0];
40+
export function getTypeTestTags(documentPath: string) {
41+
const basename = path.basename(documentPath).split('.')[0];
42+
const type = basename.split('_')[0];
4243

43-
if (ALERTING_DOCS.has(stem)) {
44+
if (ALERTING_DOCS.has(basename)) {
4445
return [type, ALERT_TAG];
4546
} else {
4647
return [type];
4748
}
4849
}
4950

51+
export function getMixedTestTags(documentPath: string) {
52+
const basename = path.basename(documentPath).split('.')[0];
53+
54+
if (ALERTING_DOCS.has(basename)) {
55+
return ['mixed', ALERT_TAG];
56+
}
57+
58+
return ['mixed'];
59+
}
60+
5061

5162
export async function runSuiteAndWriteResults(suite: Suite) {
5263
const targetDirectory = path.resolve(`${__dirname}/../../etc`);

test/bench/granular/date.bench.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
ITERATIONS,
77
LIBRARY_SPEC,
88
WARMUP,
9-
getTags
9+
getTypeTestTags
1010
} from './common';
1111

1212
const OPTIONS = {
@@ -19,7 +19,7 @@ async function main() {
1919
const testDocs = await getTestDocs('date');
2020

2121
for (const documentPath of testDocs) {
22-
const tags = getTags(documentPath);
22+
const tags = getTypeTestTags(documentPath);
2323
for (const operation of OPERATIONS) {
2424
suite.task({
2525
documentPath,

test/bench/granular/decimal128.bench.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
ITERATIONS,
77
LIBRARY_SPEC,
88
WARMUP,
9-
getTags
9+
getTypeTestTags
1010
} from './common';
1111

1212
const OPTIONS = {
@@ -23,7 +23,7 @@ async function main() {
2323
const suite = new Suite('Decimal128');
2424
const testDocs = await getTestDocs('decimal128');
2525
for (const documentPath of testDocs) {
26-
const tags = getTags(documentPath);
26+
const tags = getTypeTestTags(documentPath);
2727
for (const operation of OPERATIONS) {
2828
suite.task({
2929
documentPath,

test/bench/granular/double.bench.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
BOOL,
77
ITERATIONS,
88
WARMUP,
9-
getTags
9+
getTypeTestTags
1010
} from './common';
1111

1212
const OPTIONS = {
@@ -21,7 +21,7 @@ async function main() {
2121
const testDocs = await getTestDocs('double');
2222

2323
for (const documentPath of testDocs) {
24-
const tags = getTags(documentPath);
24+
const tags = getTypeTestTags(documentPath);
2525
// deserialize
2626
for (const promoteValues of BOOL) {
2727
suite.task({

test/bench/granular/int32.bench.ts

Lines changed: 3 additions & 2 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+
getTypeTestTags
910
} from './common';
1011

1112
const OPTIONS = {
@@ -23,7 +24,7 @@ async function main() {
2324
const suite = new Suite('Int32');
2425
const testDocs = await getTestDocs('int32');
2526
for (const documentPath of testDocs) {
26-
const tags = getTags(documentPath);
27+
const tags = getTypeTestTags(documentPath);
2728
// deserialize
2829
for (const promoteValues of BOOL) {
2930
suite.task({

test/bench/granular/long.bench.ts

Lines changed: 3 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, getTags } from './common';
2+
import { getTestDocs, runSuiteAndWriteResults, ITERATIONS, LIBRARY_SPEC, WARMUP, getTypeTestTags } from './common';
33

44
const JSBSONDeserializationOptions = [
55
{
@@ -29,7 +29,7 @@ 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);
32+
const tags = getTypeTestTags(documentPath);
3333
for (const options of JSBSONDeserializationOptions) {
3434
suite.task({
3535
documentPath,
@@ -45,7 +45,7 @@ async function main() {
4545

4646
// LONG JS-BSON Serialization tests
4747
for (const documentPath of testDocs) {
48-
const tags = getTags(documentPath);
48+
const tags = getTypeTestTags(documentPath);
4949
for (const options of JSBSONSerializationOptions) {
5050
suite.task({
5151
documentPath,

test/bench/granular/maxkey.bench.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
OPERATIONS,
77
ITERATIONS,
88
WARMUP,
9-
getTags
9+
getTypeTestTags
1010
} from './common';
1111

1212
const OPTIONS = {
@@ -21,7 +21,7 @@ async function main() {
2121
const testDocs = await getTestDocs('maxkey');
2222

2323
for (const documentPath of testDocs) {
24-
const tags = getTags(documentPath);
24+
const tags = getTypeTestTags(documentPath);
2525
for (const operation of OPERATIONS) {
2626
suite.task({
2727
documentPath,

test/bench/granular/minkey.bench.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
OPERATIONS,
77
ITERATIONS,
88
WARMUP,
9-
getTags
9+
getTypeTestTags
1010
} from './common';
1111

1212
const OPTIONS = {
@@ -22,7 +22,7 @@ async function main() {
2222

2323
for (const operation of OPERATIONS) {
2424
for (const documentPath of testDocs) {
25-
const tags = getTags(documentPath);
25+
const tags = getTypeTestTags(documentPath);
2626
suite.task({
2727
documentPath,
2828
library: LIBRARY_SPEC,

test/bench/granular/mixed.bench.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ async function main() {
4040
iterations: ITERATIONS,
4141
warmup: WARMUP,
4242
operation,
43-
options: OPTIONS[operation]
43+
options: OPTIONS[operation],
44+
tags: ['mixed']
4445
});
4546
}
4647
}

test/bench/granular/null.bench.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
OPERATIONS,
77
ITERATIONS,
88
WARMUP,
9-
getTags
9+
getTypeTestTags
1010
} from './common';
1111

1212
async function main() {
@@ -15,7 +15,7 @@ async function main() {
1515
const testDocs = await getTestDocs('null');
1616

1717
for (const documentPath of testDocs) {
18-
const tags = getTags(documentPath);
18+
const tags = getTypeTestTags(documentPath);
1919
for (const operation of OPERATIONS) {
2020
suite.task({
2121
documentPath,

test/bench/granular/objectid.bench.ts

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

1112
async function main() {
1213
const suite = new Suite('ObjectId');
1314
const testDocs = await getTestDocs('objectid');
1415

1516
for (const documentPath of testDocs) {
16-
const tags = getTags(documentPath);
17+
const tags = getTypeTestTags(documentPath);
1718
for (const operation of OPERATIONS) {
1819
suite.task({
1920
documentPath,

test/bench/granular/regexp.bench.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
ITERATIONS,
77
WARMUP,
88
BOOL,
9-
getTags
9+
getTypeTestTags
1010
} from './common';
1111

1212
async function main() {
@@ -15,7 +15,7 @@ async function main() {
1515
const testDocs = await getTestDocs('regex');
1616

1717
for (const documentPath of testDocs) {
18-
const tags = getTags(documentPath);
18+
const tags = getTypeTestTags(documentPath);
1919
// deserialize
2020
for (const bsonRegExp of BOOL) {
2121
suite.task({

test/bench/granular/string.bench.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
ITERATIONS,
77
WARMUP,
88
BOOL,
9-
getTags
9+
getTypeTestTags
1010
} from './common';
1111

1212
async function main() {
@@ -16,7 +16,7 @@ async function main() {
1616

1717
// deserialize
1818
for (const documentPath of testDocs) {
19-
const tags = getTags(documentPath);
19+
const tags = getTypeTestTags(documentPath);
2020
for (const utf8 of BOOL) {
2121
suite.task({
2222
documentPath,
@@ -31,7 +31,7 @@ async function main() {
3131
}
3232
// serialize
3333
for (const documentPath of testDocs) {
34-
const tags = getTags(documentPath);
34+
const tags = getTypeTestTags(documentPath);
3535
suite.task({
3636
documentPath,
3737
library: LIBRARY_SPEC,

test/bench/granular/timestamp.bench.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import {
66
OPERATIONS,
77
ITERATIONS,
88
WARMUP,
9-
getTags
9+
getTypeTestTags
1010
} from './common';
1111

1212
async function main() {
1313
const suite = new Suite('Timestamp');
1414
const testDocs = await getTestDocs('timestamp');
1515

1616
for (const documentPath of testDocs) {
17-
const tags = getTags(documentPath);
17+
const tags = getTypeTestTags(documentPath);
1818
for (const operation of OPERATIONS) {
1919
suite.task({
2020
documentPath,

0 commit comments

Comments
 (0)