Skip to content

Commit 7497170

Browse files
committed
fix(benchmark): Correctly await promises in async benchmarks
1 parent 21aab98 commit 7497170

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

benchmark/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ class BenchSuite extends Suite {
5252
addEval(test) {
5353
try {
5454
const evaluate = env.parse(test.expression)
55-
return this.add(benchLabel('eval', test), evaluate.bind(null, test.context))
55+
evaluate.check()
56+
const fn = evaluate.ast.maybeAsync
57+
? async () => evaluate(test.context)
58+
: () => evaluate(test.context)
59+
60+
return this.add(benchLabel('eval', test), fn)
5661
} catch (err) {
5762
err.message = `Error in test "${test.name}": ${err.message}`
5863
throw err

0 commit comments

Comments
 (0)