Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

allow deferred executions to set elapsed time #239

Open
ascidian opened this issue Jan 20, 2021 · 0 comments
Open

allow deferred executions to set elapsed time #239

ascidian opened this issue Jan 20, 2021 · 0 comments

Comments

@ascidian
Copy link

ascidian commented Jan 20, 2021

Use Case

To benchmark key performance metrics of libraries one needs to execute test cases in a Worker thread to disable JIT compiler optimizations. In my case, I am benchmarking the parsing performance of different ECMAScript parsers. While benchmark.js allows for deferred execution of test cases, it measures the elapsed time of the entire run (including setting up a Worker, loading libraries, etc.). There must be a way to only measure the key metrics such as parsing performance in a Worker thread.

Proposed Solution

Let deferred.resolve() specify the elapsed time as deferred.resolve({elapsed: elapsed}). Also expose the timing routines of benchmark.js to be included in a worker thread if that is deemed necessary.

Workaround

Currently the following workaround works with some limitations.

deferred.resolve();
deferred.benchmark.minTime = 0;
deferred.elapsed = event.elapsed; // from worker

The main side effect of this workaround is that each cycle has a single run of a test case (which probably is inadequate for some cases?). In my case, I am measuring the elapsed time in the worker using the high resolution timer available as performance.now().

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant