Skip to content

Commit 92b52eb

Browse files
comments
1 parent bba94c6 commit 92b52eb

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

test/benchmarks/mongoBench/runner.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function calculateMicroBench(benchmark, data) {
3939
const rawData = data.rawData;
4040
const count = data.count;
4141

42-
const sortedData = [].concat(rawData).sort();
42+
const sortedData = [].concat(rawData).sort((a, b) => a - b);
4343

4444
const percentiles = PERCENTILES.reduce((acc, pct) => {
4545
acc[pct] = sortedData[percentileIndex(pct, count)];
@@ -57,7 +57,7 @@ class Runner {
5757
this.minExecutionTime = options.minExecutionTime || CONSTANTS.DEFAULT_MIN_EXECUTION_TIME;
5858
this.maxExecutionTime = options.maxExecutionTime || CONSTANTS.DEFAULT_MAX_EXECUTION_TIME;
5959
this.minExecutionCount = options.minExecutionCount || CONSTANTS.DEFAULT_MIN_EXECUTION_COUNT;
60-
this.minExecutionCount = options.maxExecutionCount || CONSTANTS.DEFAULT_MAX_EXECUTION_COUNT;
60+
this.maxExecutionCount = options.maxExecutionCount || CONSTANTS.DEFAULT_MAX_EXECUTION_COUNT;
6161
this.reporter =
6262
options.reporter ||
6363
function () {
@@ -127,6 +127,7 @@ class Runner {
127127
for (const [name, benchmark] of benchmarks) {
128128
this.reporter(` Executing Benchmark "${name}"`);
129129
result[name] = await this._runBenchmark(benchmark);
130+
this.reporter(` Executed Benchmark "${name}" =`, result[name]);
130131
}
131132

132133
return result;
@@ -163,7 +164,7 @@ class Runner {
163164
const minExecutionCount = this.minExecutionCount;
164165
const minExecutionTime = this.minExecutionTime;
165166
const maxExecutionTime = this.maxExecutionTime;
166-
const maxExecutionAttempts = this.minExecutionCount;
167+
const maxExecutionAttempts = this.maxExecutionCount;
167168
let time = performance.now() - start;
168169
let count = 1;
169170

@@ -172,7 +173,7 @@ class Runner {
172173
while (
173174
time < maxExecutionTime &&
174175
(time < minExecutionTime || count < minExecutionCount) &&
175-
count < maxExecutionAttempts
176+
count <= maxExecutionAttempts
176177
) {
177178
await benchmark.beforeTask.call(ctx);
178179
const executionTime = await taskTimer(benchmark.task, ctx);
@@ -187,9 +188,12 @@ class Runner {
187188
};
188189
}
189190

190-
_errorHandler(e) {
191-
console.error(e);
192-
return NaN;
191+
_errorHandler(error) {
192+
this.reporter(`Error: ${error.name} - ${error.message} - ${error.stack}`);
193+
for (let error = error.cause; error != null; error = error.cause) {
194+
this.reporter(`Caused by: ${error.name} - ${error.message} - ${error.stack}`);
195+
}
196+
throw error;
193197
}
194198
}
195199

0 commit comments

Comments
 (0)