allow deferred executions to set elapsed time
Opened this issue · 0 comments
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()
.