Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Overhead from creating closure
(version: 0)
Comparing performance of:
create closure every time vs reuse closure
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var data = Array(200).map(_ => Math.floor(1000*Math.random())); function foo() { let same = 0; for (let i = 0; i < data.length; i++) { for (let j = 0; j < data.length; j++) { if (i==j) continue; const compare = () => { if (data[i] == data[j]) { same++; } } compare() } } return same } function bar() { let same = 0; const compare = (a, b) => { return a === b } for (let i = 0; i < data.length; i++) { for (let j = 0; j < data.length; j++) { if (i==j) continue; if (compare(data[i], data[j])) { same++; } } } return same }
Tests:
create closure every time
foo()
reuse closure
bar()
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
create closure every time
reuse closure
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!
Related benchmarks:
JavaScript spread operator vs Slice/Splice performance - 2
JavaScript spread vs slice vs for
JavaScript spread operator vs Slice/Splice performance 2
fill array with value: map(callback) vs fill(value) 2
Array.from VS spreading for
Comments
Confirm delete:
Do you really want to delete benchmark?