Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
createElementNS vs cloneNode
(version: 1)
Faster way to create new dom elements before insertion
Comparing performance of:
createElementNS vs cloneNode (shallow) vs cloneNode (deep)
Created:
10 months ago
by:
Guest
Jump to the latest result
Tests:
createElementNS
const list = [] let n = 1e5 while (--n) { const c = document.createElementNS('http://www.w3.org/2000/svg', 'circle') c.setAttribute('cx', 39) c.setAttribute('cy', 0) c.setAttribute('r', 20) list.push(c) }
cloneNode (shallow)
const list = [] let n = 1e5 - 1 const c = document.createElementNS('http://www.w3.org/2000/svg', 'circle') c.setAttribute('cx', 39) c.setAttribute('cy', 0) c.setAttribute('r', 20) list.push(c) while (--n) { list.push(c.cloneNode(false)) }
cloneNode (deep)
const list = [] let n = 1e5 - 1 const c = document.createElementNS('http://www.w3.org/2000/svg', 'circle') c.setAttribute('cx', 39) c.setAttribute('cy', 0) c.setAttribute('r', 20) list.push(c) while (--n) { list.push(c.cloneNode(true)) }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
createElementNS
cloneNode (shallow)
cloneNode (deep)
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:147.0) Gecko/20100101 Firefox/147.0
Browser/OS:
Firefox 147 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
createElementNS
16.2 Ops/sec
cloneNode (shallow)
27.9 Ops/sec
cloneNode (deep)
28.0 Ops/sec
Related benchmarks:
createElement vs cloneNode
createElement vs cloneNode shallow
createElement vs cloneNode shallow2
createElement vs cloneNode(false)
createElement vs cloneNode()
createElement vs cloneNode 2
createElement vs cloneNode 1337
createElement vs cloneNode ㅠ53152 324
createElement vs cloneNode ㅠ53152 3241412 v
Comments
Confirm delete:
Do you really want to delete benchmark?