Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(NODE-6756): add tags to benchmarks #751

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,181 changes: 1,741 additions & 1,440 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions test/bench/granular/binary.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import {
BOOL,
ITERATIONS,
LIBRARY_SPEC,
WARMUP
WARMUP,
getTypeTestTags
} from './common';

async function main() {
const suite = new Suite('Binary');
const testDocs = await getTestDocs('binary');
// deserialize
for (const documentPath of testDocs) {
const tags = getTypeTestTags(documentPath);
for (const promoteBuffers of BOOL) {
suite.task({
documentPath,
Expand All @@ -22,7 +24,8 @@ async function main() {
operation: 'deserialize',
options: {
promoteBuffers
}
},
tags
});
}

Expand All @@ -33,7 +36,8 @@ async function main() {
iterations: ITERATIONS,
warmup: WARMUP,
operation: 'serialize',
options: { checkKeys: true, ignoreUndefined: false }
options: { checkKeys: true, ignoreUndefined: false },
tags
});
}
await runSuiteAndWriteResults(suite);
Expand Down
11 changes: 8 additions & 3 deletions test/bench/granular/boolean.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
BOOL,
ITERATIONS,
WARMUP,
LIBRARY_SPEC
LIBRARY_SPEC,
getTypeTestTags
} from './common';

const OPTIONS = {
Expand All @@ -21,27 +22,31 @@ async function main() {
const testDocs = await getTestDocs('boolean');
// deserialize
for (const documentPath of testDocs) {
const tags = getTypeTestTags(documentPath);
for (const promoteValues of BOOL) {
suite.task({
documentPath,
library: LIBRARY_SPEC,
iterations: ITERATIONS,
warmup: WARMUP,
operation: 'deserialize',
options: { ...OPTIONS.deserialize, promoteValues }
options: { ...OPTIONS.deserialize, promoteValues },
tags
});
}
}

// serialize
for (const documentPath of testDocs) {
const tags = getTypeTestTags(documentPath);
suite.task({
documentPath,
library: LIBRARY_SPEC,
iterations: ITERATIONS,
warmup: WARMUP,
operation: 'deserialize',
options: OPTIONS.serialize
options: OPTIONS.serialize,
tags
});
}
await runSuiteAndWriteResults(suite);
Expand Down
11 changes: 7 additions & 4 deletions test/bench/granular/code.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
OPERATIONS,
ITERATIONS,
LIBRARY_SPEC,
WARMUP
WARMUP,
getTypeTestTags
} from './common';

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

for (const operation of OPERATIONS) {
for (const documentPath of testDocs) {
for (const documentPath of testDocs) {
const tags = getTypeTestTags(documentPath);
for (const operation of OPERATIONS) {
suite.task({
documentPath,
library: LIBRARY_SPEC,
iterations: ITERATIONS,
warmup: WARMUP,
operation,
options: OPTIONS[operation]
options: OPTIONS[operation],
tags
});
}
}
Expand Down
33 changes: 33 additions & 0 deletions test/bench/granular/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,39 @@ export async function getTestDocs(type: string) {
return docs;
}

const ALERTING_DOCS = new Set([
'objectid_array_1000.json',
'double_array_1000.json',
'int32_array_1000.json',
'long_array_1000.json',
'string_array_1000.json',
'binary_array_1000.json',
'bestbuy_medium.json'
]);

export const ALERT_TAG = 'alerting-benchmark';

export function getTypeTestTags(documentPath: string) {
const basename = path.basename(documentPath).split('.')[0];
const type = basename.split('_')[0];

if (ALERTING_DOCS.has(basename)) {
return [type, ALERT_TAG];
} else {
return [type];
}
}

export function getMixedTestTags(documentPath: string) {
const basename = path.basename(documentPath).split('.')[0];

if (ALERTING_DOCS.has(basename)) {
return ['mixed', ALERT_TAG];
}

return ['mixed'];
}

export async function runSuiteAndWriteResults(suite: Suite) {
const targetDirectory = path.resolve(`${__dirname}/../../etc`);
await suite.run();
Expand Down
11 changes: 7 additions & 4 deletions test/bench/granular/date.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
OPERATIONS,
ITERATIONS,
LIBRARY_SPEC,
WARMUP
WARMUP,
getTypeTestTags
} from './common';

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

for (const operation of OPERATIONS) {
for (const documentPath of testDocs) {
for (const documentPath of testDocs) {
const tags = getTypeTestTags(documentPath);
for (const operation of OPERATIONS) {
suite.task({
documentPath,
library: LIBRARY_SPEC,
iterations: ITERATIONS,
warmup: WARMUP,
operation,
options: OPTIONS[operation]
options: OPTIONS[operation],
tags
});
}
}
Expand Down
11 changes: 7 additions & 4 deletions test/bench/granular/decimal128.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
OPERATIONS,
ITERATIONS,
LIBRARY_SPEC,
WARMUP
WARMUP,
getTypeTestTags
} from './common';

const OPTIONS = {
Expand All @@ -21,15 +22,17 @@ const OPTIONS = {
async function main() {
const suite = new Suite('Decimal128');
const testDocs = await getTestDocs('decimal128');
for (const operation of OPERATIONS) {
for (const documentPath of testDocs) {
for (const documentPath of testDocs) {
const tags = getTypeTestTags(documentPath);
for (const operation of OPERATIONS) {
suite.task({
documentPath,
library: LIBRARY_SPEC,
iterations: ITERATIONS,
warmup: WARMUP,
operation,
options: OPTIONS[operation]
options: OPTIONS[operation],
tags
});
}
}
Expand Down
10 changes: 7 additions & 3 deletions test/bench/granular/double.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
LIBRARY_SPEC,
BOOL,
ITERATIONS,
WARMUP
WARMUP,
getTypeTestTags
} from './common';

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

for (const documentPath of testDocs) {
const tags = getTypeTestTags(documentPath);
// deserialize
for (const promoteValues of BOOL) {
suite.task({
Expand All @@ -28,7 +30,8 @@ async function main() {
iterations: ITERATIONS,
warmup: WARMUP,
operation: 'deserialize',
options: { ...OPTIONS.deserialize, promoteValues }
options: { ...OPTIONS.deserialize, promoteValues },
tags
});
}

Expand All @@ -39,7 +42,8 @@ async function main() {
iterations: ITERATIONS,
warmup: WARMUP,
operation: 'serialize',
options: OPTIONS.serialize
options: OPTIONS.serialize,
tags
});
}
await runSuiteAndWriteResults(suite);
Expand Down
10 changes: 7 additions & 3 deletions test/bench/granular/int32.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
LIBRARY_SPEC,
BOOL,
ITERATIONS,
WARMUP
WARMUP,
getTypeTestTags
} from './common';

const OPTIONS = {
Expand All @@ -23,6 +24,7 @@ async function main() {
const suite = new Suite('Int32');
const testDocs = await getTestDocs('int32');
for (const documentPath of testDocs) {
const tags = getTypeTestTags(documentPath);
// deserialize
for (const promoteValues of BOOL) {
suite.task({
Expand All @@ -31,7 +33,8 @@ async function main() {
iterations: ITERATIONS,
warmup: WARMUP,
operation: 'deserialize',
options: { ...OPTIONS.deserialize, promoteValues }
options: { ...OPTIONS.deserialize, promoteValues },
tags
});
}
//serialize
Expand All @@ -41,7 +44,8 @@ async function main() {
iterations: ITERATIONS,
warmup: WARMUP,
operation: 'serialize',
options: OPTIONS.serialize
options: OPTIONS.serialize,
tags
});
}
await runSuiteAndWriteResults(suite);
Expand Down
17 changes: 14 additions & 3 deletions test/bench/granular/long.bench.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { Suite } from 'dbx-js-tools/packages/bson-bench';
import { getTestDocs, runSuiteAndWriteResults, ITERATIONS, LIBRARY_SPEC, WARMUP } from './common';
import {
getTestDocs,
runSuiteAndWriteResults,
ITERATIONS,
LIBRARY_SPEC,
WARMUP,
getTypeTestTags
} from './common';

const JSBSONDeserializationOptions = [
{
Expand Down Expand Up @@ -29,28 +36,32 @@ async function main() {
const testDocs = await getTestDocs('long');
// LONG JS-BSON Deserialization tests
for (const documentPath of testDocs) {
const tags = getTypeTestTags(documentPath);
for (const options of JSBSONDeserializationOptions) {
suite.task({
documentPath,
library: LIBRARY_SPEC,
iterations: ITERATIONS,
warmup: WARMUP,
operation: 'deserialize',
options
options,
tags
});
}
}

// LONG JS-BSON Serialization tests
for (const documentPath of testDocs) {
const tags = getTypeTestTags(documentPath);
for (const options of JSBSONSerializationOptions) {
suite.task({
documentPath,
library: LIBRARY_SPEC,
iterations: ITERATIONS,
warmup: WARMUP,
operation: 'serialize',
options
options,
tags
});
}
}
Expand Down
11 changes: 7 additions & 4 deletions test/bench/granular/maxkey.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
LIBRARY_SPEC,
OPERATIONS,
ITERATIONS,
WARMUP
WARMUP,
getTypeTestTags
} from './common';

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

for (const operation of OPERATIONS) {
for (const documentPath of testDocs) {
for (const documentPath of testDocs) {
const tags = getTypeTestTags(documentPath);
for (const operation of OPERATIONS) {
suite.task({
documentPath,
library: LIBRARY_SPEC,
iterations: ITERATIONS,
warmup: WARMUP,
operation,
options: OPTIONS[operation]
options: OPTIONS[operation],
tags
});
}
}
Expand Down
7 changes: 5 additions & 2 deletions test/bench/granular/minkey.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
LIBRARY_SPEC,
OPERATIONS,
ITERATIONS,
WARMUP
WARMUP,
getTypeTestTags
} from './common';

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

for (const operation of OPERATIONS) {
for (const documentPath of testDocs) {
const tags = getTypeTestTags(documentPath);
suite.task({
documentPath,
library: LIBRARY_SPEC,
iterations: ITERATIONS,
warmup: WARMUP,
operation,
options: OPTIONS[operation]
options: OPTIONS[operation],
tags
});
}
}
Expand Down
Loading