Skip to content

Commit 43fc00b

Browse files
committed
chore(NODE-6921): default to cwd and errexit
1 parent 64ff6a2 commit 43fc00b

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

.evergreen/run-granular-benchmarks.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/env bash
22

33
source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh
4-
set -o xtrace
5-
WARMUP=$WARMUP
6-
ITERATIONS=$ITERATIONS
74

8-
WARMUP=$WARMUP ITERATIONS=$ITERATIONS LIBRARY=$(pwd) npm run check:granular-bench
5+
set -euxo pipefail
6+
7+
export WARMUP=$WARMUP
8+
export ITERATIONS=$ITERATIONS
9+
10+
npm run check:granular-bench

.evergreen/run-spec-benchmarks.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh
44

5+
set -euxo pipefail
6+
57
npm run check:spec-bench

CONTRIBUTING.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,16 @@ WARMUP=<warmup iterations> ITERATIONS=<measured iterations> npm run check:granul
8383
This will build the granular tests and run them with `test/bench/etc/run_granular_benchmarks.js`. The `WARMUP` and `ITERATIONS` environment variables can be optionally provided to configure how these granular benchmarks
8484
are run. `WARMUP` changes the number of iterations run before results are collected to give v8's
8585
optimizing compiler time to reach steady state. `ITERATIONS` changes the number of iterations that
86-
are measured and used to calculate summary statistics. Note also that the test can be configured to
87-
make use of the local copy of bson when testing performance changes locally by setting the `LIBRARY`
88-
variable to the root directory of the bson library to be tested.
86+
are measured and used to calculate summary statistics.
8987

9088
```bash
91-
WARMUP=100 ITERATIONS=1000 LIBRARY=$(pwd) npm run check:granular-bench
89+
WARMUP=100 ITERATIONS=1000 npm run check:granular-bench
9290
```
93-
When the `LIBRARY` environment variable is unset, the benchmark clones and runs against the main
94-
branch of this repository.
91+
92+
When the `LIBRARY` environment variable is unset, the benchmark clones and runs against the current working directory.
93+
94+
> [!NOTE]
95+
> The test can be configured to make use of a different copy of bson when testing performance changes locally by setting the `LIBRARY` variable to the root directory of a copy of the bson library.
9596
9697
When the script is complete, results will be output to `test/bench/etc/resultsCollectedMeans.json`. These results will
9798
be in a format compatible with evergreen's perf.send command. To convert these results to CSV, run
@@ -109,14 +110,15 @@ npm run check:spec-bench
109110

110111
This will run the spec benchmarks in `test/bench/spec/bsonBench.ts` which also makes use of the
111112
`bson-bench` library. Results will be written to `bsonBench`. The warmup and iterations are not
112-
configurable as these are determined by the common driver benchmarking specification, but similar
113-
to the granular benchmarks, the spec benchmarks can be run against the local copy of bson by setting
114-
the `LIBRARY` environment variable appropriately.
113+
configurable as these are determined by the common driver benchmarking specification.
115114

116115
```bash
117-
LIBRARY=$(pwd) npm run check:spec-bench
116+
npm run check:spec-bench
118117
```
119118

119+
> [!NOTE]
120+
> The test can be configured to make use of a different copy of bson when testing performance changes locally by setting the `LIBRARY` variable to the root directory of a copy of the bson library.
121+
120122
### Commit messages
121123

122124
Please follow the [Conventional Commits specification][conventional-commit-style].

test/bench/granular/common.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Suite } from 'dbx-js-tools/packages/bson-bench';
2+
import * as process from 'process';
23
import * as path from 'path';
34
import * as fs from 'fs/promises';
45

@@ -71,7 +72,7 @@ export function readEnvVars(): { warmup: number; iterations: number; library: st
7172
const rv = {
7273
warmup: Number.isSafeInteger(envWarmup) && envWarmup > 0 ? envWarmup : 100_000,
7374
iterations: Number.isSafeInteger(envIterations) && envIterations > 0 ? envIterations : 10_000,
74-
library: libraryPath ? `bson:${libraryPath}` : 'bson#main'
75+
library: libraryPath ? `bson:${libraryPath}` : `bson:${process.cwd()}`
7576
};
7677

7778
console.log(

0 commit comments

Comments
 (0)