Skip to content

Commit 39ce9a7

Browse files
author
Bart Veneman
committed
update benchmarks
1 parent 2e98428 commit 39ce9a7

File tree

6 files changed

+39
-127
lines changed

6 files changed

+39
-127
lines changed

benchmark/benchmark.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

benchmark/memory.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

benchmark/parse-analyze-ratio.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ files.forEach(([, name]) => {
2222
}
2323
})
2424

25-
console.log('Running benchmark on /dist/analyzer.js:')
25+
console.log('Running benchmark on /dist/analyzer.modern.js:')
2626
const header = `${'File'.padEnd(maxLen + 2)} | ${'Size'.padStart(7)} | total | parse | Analyze |`
2727
console.log(''.padEnd(header.length, '='))
2828
console.log(header)

benchmark/readme.md

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
# Benchmarks
22

3-
## Analyzing
4-
5-
`node benchmark/benchmark.js`
3+
## Running time
64

75
```
8-
Bol.com (468 kB): 10.07 ops/sec
9-
Bootstrap 5.0.0 (195 kB): 23.98 ops/sec
10-
CSS-Tricks (195 kB): 23.00 ops/sec
11-
Facebook.com (268 kB): 15.66 ops/sec
12-
GitHub.com (514 kB): 11.47 ops/sec
13-
Gazelle.nl (972 kB): 3.38 ops/sec
14-
Lego.com (246 kB): 19.81 ops/sec
15-
Smashing Magazine.com (1.1 MB): 3.79 ops/sec
16-
Trello.com (312 kB): 13.15 ops/sec
6+
Bol.com ( 468 kB) 120ms
7+
Bootstrap 5.0.0 ( 195 kB) 50ms
8+
CNN (1.77 MB) 377ms
9+
CSS-Tricks ( 195 kB) 54ms
10+
Facebook.com ( 268 kB) 75ms
11+
GitHub.com ( 514 kB) 93ms
12+
Gazelle.nl ( 972 kB) 307ms
13+
Lego.com ( 246 kB) 56ms
14+
Smashing Magazine.com ( 1.1 MB) 298ms
15+
Trello.com ( 312 kB) 82ms
1716
```
1817

1918
## Parsing vs. analyzing
@@ -24,14 +23,14 @@ Trello.com (312 kB): 13.15 ops/sec
2423
=====================================================================
2524
File | Size | total | parse | Analyze |
2625
=====================================================================
27-
Bol.com | 468 kB | 330ms | 207ms | 122ms (37.0%) |
28-
Bootstrap 5.0.0 | 195 kB | 122ms | 87ms | 34ms (27.9%) |
29-
CSS-Tricks | 195 kB | 98ms | 64ms | 34ms (34.7%) |
30-
CNN | 1.77 MB | 563ms | 367ms | 193ms (34.3%) |
31-
Facebook.com | 268 kB | 96ms | 49ms | 47ms (49.0%) |
32-
GitHub.com | 514 kB | 161ms | 79ms | 80ms (49.7%) |
33-
Gazelle.nl | 972 kB | 343ms | 215ms | 124ms (36.2%) |
34-
Lego.com | 246 kB | 73ms | 37ms | 35ms (47.9%) |
35-
Smashing Magazine.com | 1.1 MB | 300ms | 162ms | 136ms (45.3%) |
36-
Trello.com | 312 kB | 84ms | 49ms | 34ms (40.5%) |
26+
Bol.com | 468 kB | 338ms | 206ms | 131ms (38.8%) |
27+
Bootstrap 5.0.0 | 195 kB | 134ms | 90ms | 37ms (27.6%) |
28+
CNN | 1.77 MB | 595ms | 393ms | 200ms (33.6%) |
29+
CSS-Tricks | 195 kB | 107ms | 72ms | 35ms (32.7%) |
30+
Facebook.com | 268 kB | 97ms | 44ms | 53ms (54.6%) |
31+
GitHub.com | 514 kB | 127ms | 53ms | 72ms (56.7%) |
32+
Gazelle.nl | 972 kB | 332ms | 212ms | 116ms (34.9%) |
33+
Lego.com | 246 kB | 66ms | 38ms | 28ms (42.4%) |
34+
Smashing Magazine.com | 1.1 MB | 311ms | 166ms | 143ms (46.0%) |
35+
Trello.com | 312 kB | 82ms | 45ms | 37ms (45.1%) |
3736
```

benchmark/run.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import byteSize from './format-filesize.js'
22
import { analyze as analyzeCss } from '../dist/analyzer.modern.js'
33
import * as fs from 'fs'
44
const files = [
5-
['bol-com-20190617', 'Bol.com', 130],
6-
['bootstrap-5.0.0', 'Bootstrap 5.0.0', 54],
7-
['cnn-20220403', 'CNN', 406],
5+
['bol-com-20190617', 'Bol.com', 121],
6+
['bootstrap-5.0.0', 'Bootstrap 5.0.0', 49],
7+
['cnn-20220403', 'CNN', 376],
88
['css-tricks-20190319', 'CSS-Tricks', 54],
9-
['facebook-20190319', 'Facebook.com', 79],
10-
['github-20210501', 'GitHub.com', 101],
11-
['gazelle-20210905', 'Gazelle.nl', 332],
12-
['lego-20190617', 'Lego.com', 63],
13-
['smashing-magazine-20190319', 'Smashing Magazine.com', 332],
14-
['trello-20190617', 'Trello.com', 86]
9+
['facebook-20190319', 'Facebook.com', 76],
10+
['github-20210501', 'GitHub.com', 93],
11+
['gazelle-20210905', 'Gazelle.nl', 311],
12+
['lego-20190617', 'Lego.com', 59],
13+
['smashing-magazine-20190319', 'Smashing Magazine.com', 302],
14+
['trello-20190617', 'Trello.com', 83]
1515
]
1616

1717
let maxLen = -1
@@ -30,25 +30,28 @@ files.forEach(([filename, name, expectedDuration]) => {
3030
const css = fs.readFileSync(`./src/__fixtures__/${filename}.css`, 'utf-8')
3131
const fileSize = byteSize(css.length)
3232
suite.push([
33-
`${name.padEnd(maxLen + 2)} (${fileSize.padStart(7)})`,
33+
`${name.padEnd(maxLen + 2)} ${fileSize.padStart(7)}`,
3434
() => analyzeCss(css),
35-
expectedDuration
35+
expectedDuration,
36+
css.length,
3637
])
3738
})
3839

3940
const RUN_COUNT = 25
4041

41-
suite.forEach(([name, fn, expectedDuration]) => {
42+
suite.forEach(([name, fn, expectedDuration, size]) => {
4243
const start = new Date()
4344
for (let i = 0; i < RUN_COUNT; i++) {
4445
fn();
4546
}
4647
const duration = Math.floor((new Date() - start) / RUN_COUNT)
4748
const overtime = expectedDuration - duration
49+
const bytesPerSecond = Math.floor(1000 / duration * size)
4850
console.log(
4951
name,
5052
`${duration}ms`.padStart(6, ' '),
51-
`(${overtime >= 0 ? '-' : '+'}${Math.abs(overtime)}ms ${Math.round(Math.abs(overtime) / duration * 100)}%)`,
53+
`(${overtime >= 0 ? '-' : '+'}${Math.abs(overtime)}ms ${Math.round(Math.abs(overtime) / duration * 100)}%)`.padStart(10),
54+
`${byteSize(bytesPerSecond)}/s`.padStart(9)
5255
)
5356
})
5457

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
"watchlist": "^0.2.3"
5454
},
5555
"mangle": {
56-
"regex": "^_"
56+
"regex": "^_[^_]"
5757
}
5858
}

0 commit comments

Comments
 (0)