Skip to content

Commit

Permalink
fix(shell-evaluator): fix exposed asyncRewrite fn for benchmarks (#1922)
Browse files Browse the repository at this point in the history
Painfully obvious bug in 0491491 :) Renamed the benchmark test
and fixed it to account for the (now very) different performance
measurements after the fix.
  • Loading branch information
addaleax authored Apr 3, 2024
1 parent 7832ccf commit a38a173
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/cli-repl/src/smoke-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ export async function runSmokeTests({
perfTestIterations: 0,
},
{
name: 'async_rewrite',
name: 'async_rewrite_foreach',
input:
'for (let i = 0; i < 100; i++) __asyncRewrite(String([].forEach)); print("done")',
'for (let i = 0; i < 100; i++) __asyncRewrite(String([].forEach).replace("function", "function forEach")); print("done")',
output: /done/,
includeStderr: false,
testArgs: ['--exposeAsyncRewriter', '--nodb'],
Expand Down
3 changes: 2 additions & 1 deletion packages/shell-evaluator/src/shell-evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ class ShellEvaluator<EvaluationResultType = ShellResult> {
}

if (this.exposeAsyncRewriter) {
(context as any).__asyncRewrite = () => this.asyncWriter.process(input);
(context as any).__asyncRewrite = (rewriteInput: string) =>
this.asyncWriter.process(rewriteInput);
}

this.markTime?.(TimingCategories.AsyncRewrite, 'start async rewrite');
Expand Down

0 comments on commit a38a173

Please sign in to comment.