Skip to content

Commit

Permalink
chore: fix benchmark result reporting (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Aug 30, 2024
1 parent 17c4541 commit 9567aa3
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions packages/bson-bench/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,34 @@ import {
type RunBenchmarkMessage
} from './common';

function reportResultAndQuit(result: BenchmarkResult) {
if (process.send) process?.send({ type: 'returnResult', result });
function exit(code: number) {
process.disconnect();
process.exit(0);
process.exit(code);
}

function reportResultAndQuit(result: BenchmarkResult) {
if (process.send) {
process.send({ type: 'returnResult', result }, null, {}, () => exit(0));
return;
}
exit(0);
}

function reportErrorAndQuit(error: Error) {
if (process.send)
process.send({
type: 'returnError',
error
});
process.disconnect();
process.exit(1);
if (process.send) {
process.send(
{
type: 'returnError',
error
},
null,
{},
() => exit(0)
);
return;
}

exit(1);
}

function run(bson: BSONLib | ConstructibleBSON, config: BenchmarkSpecification) {
Expand Down

0 comments on commit 9567aa3

Please sign in to comment.