Comments (6)
Upon further examination this appears to be a difference between Benchmark.prototype.onStart
and benchmark.events.start
. Why the difference? I would assume that using onStart
verses on("start",...)
would net the same affect.
from benchmark.js.
Internally the benchmark is cloned to collect a sample of runs, by setting the Benchmark.options.onStart
you're adding that as the default onStart for all benchmarks created (even the internal clones).
from benchmark.js.
While I understand what is going on internally with cloned benchmarks, the difference in behavior between benchmark.onStart
and adding an event listener with benchmark.on("start", ...)
seems unintuitive. The confusion arises because I am used to the DOM event model where DOMElement.onClick = ...
and DOMElement.addEventListener("click", ...
behave the same.
from benchmark.js.
Benchmark.options
is the default options for all benchmarks created. The Benchmark
constructor accepts an options object where onStart
can be specified or later on the benchmark instance via myBench.on('start', ...)
.
from benchmark.js.
Thank you for the clarification. It seems onStart
should never be directly set on a benchmark object. Correct me if I'm wrong @jdalton, but when a benchmark is cloned the original benchmark itself acts as the options object during the construction of the clone.
If I may ask one more rhetorical question, would it not make sense that clones created internally during run
have their events cleared? I say this because benchmark.onStart
benchmark.onCycle
and benchmark.onComplete
should accomplish everything needed.
from benchmark.js.
There is no mybench.onStart
, or mybench.onCycle
or mybench.onComplete
. There are options properties for onStart
, onCycle
and the rest. The clones are created with their event listeners mandated to them.
from benchmark.js.
Related Issues (20)
- Is there a working fork of this repo? HOT 1
- Add a guide on how to import Benchmark with a module bundler HOT 1
- Document how benchmark.js works
- allow deferred executions to set elapsed time
- Consider performance.now() HOT 8
- Help handling errors in defer mode
- Not usable in TS. HOT 5
- Suite not found when bundling with Rollup HOT 1
- `Benchmark` may not be browser global in ESM bundle
- Document how to run benchmark.js HOT 1
- Consider using symbols for tracing data
- TypeError: Cannot read properties of undefined (reading 'parentNode')
- What is the "x runs sampled" in the output results?
- How do I get the same test results every time? HOT 1
- Too many significant digits being reported
- [Q] How to determine that all benchmarks are met?
- [Q] Is it possible to describe an asynchronous event handler?
- [Q] How to setup delay between benchmarks?
- Baseline measurements
- Memory exhaustion because all calls of async function seem to be happening concurrently HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from benchmark.js.