Skip to content

Commit 87bceff

Browse files
committed
Initial commit
1 parent cf92958 commit 87bceff

File tree

12 files changed

+4400
-1
lines changed

12 files changed

+4400
-1
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/node_modules/
2+
/.wireit/
3+
/benchmarks/**/*.js
4+
/benchmarks/**/*.js.map
5+
/benchmarks/**/*.d.ts
6+
/benchmarks/**/*.d.ts.map

LICENSE

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2023 Google LLC. All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

+39-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,39 @@
1-
# platform-benchmarks
1+
# Lit platform benchmarks
2+
3+
This repo contains a set of micro-benchmarks of basic platform APIs.
4+
5+
The benchmarks are useful to measure the performance fundamental operations across different DOM and JavaScript techniques and different browsers.
6+
7+
## Benchmarks
8+
9+
### dirty-check-attributes
10+
11+
This benchmark measures the performance impact of dirty-checking values before calling `setAttribute()``.
12+
13+
It measures three techniques:
14+
- always call `setAttribute()`` (no dirty-check)
15+
- dirty check against the DOM (with `getAttribute()`)
16+
- dirty check against a stored JS value
17+
18+
```sh
19+
npm run bench:dirty-check-attributes
20+
```
21+
22+
### dirty-check-text-content
23+
24+
This benchmark measures the performance impact of dirty-checking values
25+
before setting `Text.textContent`.
26+
27+
It measures three techniques:
28+
- always call `textContent` (no dirty-check)
29+
- dirty check against the DOM
30+
- dirty check against a stored JS value
31+
32+
## Future benchmarks
33+
- Setting `.textContent` vs `.data`
34+
- `append()` vs `insertBefore()`
35+
- `template.innerHTML` vs `DOMParser`
36+
- template clone vs imperative DOM construction
37+
- Reusing TreeWalkers
38+
- Finding nodes with TreeWalker + comments vs query selectors, etc
39+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!doctype html>
2+
<html>
3+
<script type="module" src="./index.js"></script>
4+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/Polymer/tachometer/master/config.schema.json",
3+
"sampleSize": 50,
4+
"timeout": 3,
5+
"benchmarks": [
6+
{
7+
"measurement": {
8+
"mode": "performance",
9+
"entryName": "result"
10+
},
11+
"expand": [
12+
{
13+
"name": "always-set",
14+
"url": "./index.html?benchmark=always-set",
15+
"expand": [
16+
{
17+
"browser": "chrome"
18+
},
19+
{
20+
"browser": "safari"
21+
},
22+
{
23+
"browser": "firefox"
24+
}
25+
]
26+
},
27+
{
28+
"name": "check-set",
29+
"url": "./index.html?benchmark=check-set",
30+
"expand": [
31+
{
32+
"browser": "chrome"
33+
},
34+
{
35+
"browser": "safari"
36+
},
37+
{
38+
"browser": "firefox"
39+
}
40+
]
41+
},
42+
{
43+
"name": "dirty-check",
44+
"url": "./index.html?benchmark=dirty-check",
45+
"expand": [
46+
{
47+
"browser": "chrome"
48+
},
49+
{
50+
"browser": "safari"
51+
},
52+
{
53+
"browser": "firefox"
54+
}
55+
]
56+
}
57+
]
58+
}
59+
]
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!doctype html>
2+
<html>
3+
<script type="module" src="./index.js"></script>
4+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/Polymer/tachometer/master/config.schema.json",
3+
"sampleSize": 50,
4+
"timeout": 3,
5+
"benchmarks": [
6+
{
7+
"measurement": {
8+
"mode": "performance",
9+
"entryName": "result"
10+
},
11+
"expand": [
12+
{
13+
"name": "always-set",
14+
"url": "./index.html?benchmark=always-set",
15+
"expand": [
16+
{
17+
"browser": "chrome"
18+
},
19+
{
20+
"browser": "safari"
21+
},
22+
{
23+
"browser": "firefox"
24+
}
25+
]
26+
},
27+
{
28+
"name": "check-set",
29+
"url": "./index.html?benchmark=check-set",
30+
"expand": [
31+
{
32+
"browser": "chrome"
33+
},
34+
{
35+
"browser": "safari"
36+
},
37+
{
38+
"browser": "firefox"
39+
}
40+
]
41+
},
42+
{
43+
"name": "dirty-check",
44+
"url": "./index.html?benchmark=dirty-check",
45+
"expand": [
46+
{
47+
"browser": "chrome"
48+
},
49+
{
50+
"browser": "safari"
51+
},
52+
{
53+
"browser": "firefox"
54+
}
55+
]
56+
}
57+
]
58+
}
59+
]
60+
}

0 commit comments

Comments
 (0)