https://github.com/nolanlawson/template-clone-demo
template.cloneNode(true) benchmark
https://github.com/nolanlawson/template-clone-demo
Last synced: 13 days ago
JSON representation
template.cloneNode(true) benchmark
- Host: GitHub
- URL: https://github.com/nolanlawson/template-clone-demo
- Owner: nolanlawson
- Created: 2023-11-23T20:37:33.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-11-26T17:15:21.000Z (over 1 year ago)
- Last Synced: 2025-03-27T22:16:32.778Z (about 1 month ago)
- Language: HTML
- Size: 32.2 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# template-clone-demo
Usage: `npm install && npm run benchmark`
## Results
M1 MacBook Pro:
```
┌─────────────┬─────────────────┐
│ Version │ │
├─────────────┼─────────────────┤
│ Browser │ chrome-headless │
│ │ 119.0.6045.159 │
├─────────────┼─────────────────┤
│ Sample size │ 51 │
├─────────────┼─────────────────┤
│ Bytes │ 2.19 KiB │
└─────────────┴─────────────────┘┌───────────────────────┬───────────────────┬──────────────────────────┬───────────────────┐
│ Benchmark │ Avg time │ vs Manual DOM operations │ vs Clone template │
├───────────────────────┼───────────────────┼──────────────────────────┼───────────────────┤
│ Manual DOM operations │ 49.03ms - 49.22ms │ │ slower │
│ │ │ - │ 94% - 95% │
│ │ │ │ 23.81ms - 24.02ms │
├───────────────────────┼───────────────────┼──────────────────────────┼───────────────────┤
│ Clone template │ 25.17ms - 25.26ms │ faster │ │
│ │ │ 49% - 49% │ - │
│ │ │ 23.81ms - 24.02ms │ │
└───────────────────────┴───────────────────┴──────────────────────────┴───────────────────┘┌─────────────┬──────────────────┐
│ Version │ │
├─────────────┼──────────────────┤
│ Browser │ firefox-headless │
│ │ 114.0 │
├─────────────┼──────────────────┤
│ Sample size │ 51 │
├─────────────┼──────────────────┤
│ Bytes │ 2.19 KiB │
└─────────────┴──────────────────┘┌───────────────────────┬───────────────────┬──────────────────────────┬───────────────────┐
│ Benchmark │ Avg time │ vs Manual DOM operations │ vs Clone template │
├───────────────────────┼───────────────────┼──────────────────────────┼───────────────────┤
│ Manual DOM operations │ 50.15ms - 50.75ms │ │ slower │
│ │ │ - │ 17% - 18% │
│ │ │ │ 7.14ms - 7.88ms │
├───────────────────────┼───────────────────┼──────────────────────────┼───────────────────┤
│ Clone template │ 42.72ms - 43.16ms │ faster │ │
│ │ │ 14% - 16% │ - │
│ │ │ 7.14ms - 7.88ms │ │
└───────────────────────┴───────────────────┴──────────────────────────┴───────────────────┘┌─────────────┬──────────┐
│ Version │ │
├─────────────┼──────────┤
│ Browser │ safari │
│ │ 16.6 │
├─────────────┼──────────┤
│ Sample size │ 51 │
├─────────────┼──────────┤
│ Bytes │ 2.19 KiB │
└─────────────┴──────────┘┌───────────────────────┬───────────────────┬──────────────────────────┬───────────────────┐
│ Benchmark │ Avg time │ vs Manual DOM operations │ vs Clone template │
├───────────────────────┼───────────────────┼──────────────────────────┼───────────────────┤
│ Manual DOM operations │ 26.69ms - 28.29ms │ │ slower │
│ │ │ - │ 8% - 15% │
│ │ │ │ 2.08ms - 3.72ms │
├───────────────────────┼───────────────────┼──────────────────────────┼───────────────────┤
│ Clone template │ 24.40ms - 24.78ms │ faster │ │
│ │ │ 8% - 13% │ - │
│ │ │ 2.08ms - 3.72ms │ │
└───────────────────────┴───────────────────┴──────────────────────────┴───────────────────┘
```