Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
event delegation: closest vs cached
(version: 0)
Comparing performance of:
manyC vs manyW
Created:
6 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<ul class='manyC'> </ul> <ul class='manyW'> </ul> <template class='content'> <li data-x='2'> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div> <a class='link'></a> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </li> </template>
Script Preparation code:
var templ = document.querySelector(`.content`); var manyC = document.querySelector(`.manyC`); var manyCLinks = []; var manyW = document.querySelector(`.manyW`); var manyWLinks = []; var x = 0; function handleEvent(li) { x += (li.dataset.x|0); } function cHandleEvent(ev) { handleEvent(ev.target.closest(`li`)); } const k = Symbol(); function wHandleEvent(ev) { let t= ev.target; let li = t[k]; if (li === undefined) { t[k] = li = ev.target.closest(`li`) } handleEvent(li); } var n = 1000; for (let i = 0; i < n; ++i) { let frag = templ.cloneNode(true).content; manyCLinks.push(frag.querySelector(`.link`)); manyC.append(frag); frag = templ.cloneNode(true).content; manyWLinks.push(frag.querySelector(`.link`)); manyW.append(frag); } debugger; manyC.addEventListener(`test`, cHandleEvent); manyW.addEventListener(`test`, wHandleEvent);
Tests:
manyC
manyCLinks[(Math.random() * n)|0].dispatchEvent(new CustomEvent(`test`, {bubbles : true}));
manyW
manyWLinks[(Math.random() * n)|0].dispatchEvent(new CustomEvent(`test`, {bubbles : true}));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
manyC
manyW
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
It appears that we're dealing with a JavaScript benchmarking test case, specifically the `manyCLinks` and `manyWLinks` tests. From the provided code snippet, I notice that the template string contains a repeating pattern of `<div>...</div>` elements. This is likely used to create multiple instances of an HTML element for each iteration in the benchmark loop. The test cases themselves define two separate benchmarks: 1. `manyCLinks`: creates 1000 links and dispatches a custom event on each one. 2. `manyWLinks`: creates 500 links and dispatches a custom event on each one. To answer your question, I'll provide a brief analysis of the latest benchmark result. **Benchmark Results:** The provided benchmark results show two sets of data: 1. **`manyWLinks`**: Chrome 108, Desktop, Windows * Executions per second: 64684.6484375 2. **`manyC`**: Chrome 108, Desktop, Windows * Executions per second: 75884.9140625 **Observations:** 1. The `manyWLinks` test is executed approximately 11% slower than the `manyCLinks` test. 2. Both tests are executed on a desktop platform with Windows as the operating system. Please note that these results are specific to this particular benchmarking test case and may not be representative of real-world performance. If you have any further questions or would like me to elaborate on any aspect of the analysis, feel free to ask!
Related benchmarks:
event delegation vs local handlers
event delegation (with parent identification) vs local handlers
event delegation: closest vs walk-up
JS Events
Comments
Confirm delete:
Do you really want to delete benchmark?