-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
101 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,39 @@ | ||
# Benchmarks | ||
|
||
Below are the benchmark results for `Node v11.14.0` and `clsx v1.0.4`. | ||
To run the benchmarks yourself use `yarn benchmark` | ||
|
||
To test these benchmarks yourself run `yarn benchmark` | ||
Case one and two are extracted from https://github.com/mui-org/material-ui | ||
|
||
Some of the cases are code extracted from https://github.com/mui-org/material-ui | ||
| | | | ||
| ---------- | ------ | | ||
| Node | 12.9.0 | | ||
| clsx | 1.0.4 | | ||
| classnames | 2.2.6 | | ||
|
||
# Results | ||
|
||
`N/A` means the function call was optimized away and no library was used | ||
|
||
``` | ||
# case_1.js - Extract properties, combine arguments, and conditional expression: | ||
before x 725,714 ops/sec ±0.41% (92 runs sampled) | ||
after x 7,403,876 ops/sec ±0.33% (92 runs sampled) | ||
before - classnames x 455,076 ops/sec ±0.29% (89 runs sampled) | ||
before - clsx x 515,270 ops/sec ±0.24% (93 runs sampled) | ||
after - classnames x 2,147,313 ops/sec ±0.29% (94 runs sampled) | ||
after - clsx x 7,170,564 ops/sec ±0.66% (89 runs sampled) | ||
# case_2.js - Extract properties and combine arguments: | ||
before x 402,253 ops/sec ±0.32% (92 runs sampled) | ||
after x 4,443,619 ops/sec ±1.53% (91 runs sampled) | ||
before - classnames x 270,775 ops/sec ±0.48% (93 runs sampled) | ||
before - clsx x 288,193 ops/sec ±0.25% (93 runs sampled) | ||
after - classnames x 1,644,390 ops/sec ±0.39% (94 runs sampled) | ||
after - clsx x 4,097,308 ops/sec ±0.63% (93 runs sampled) | ||
# case_3.js - String literals: | ||
before x 7,271,738 ops/sec ±0.96% (92 runs sampled) | ||
after x 850,938,371 ops/sec ±0.25% (93 runs sampled) | ||
# case_3.js - Object with string literals: | ||
before - classnames x 3,579,582 ops/sec ±0.38% (91 runs sampled) | ||
before - clsx x 7,029,547 ops/sec ±0.58% (89 runs sampled) | ||
after - N/A x 851,510,031 ops/sec ±0.26% (92 runs sampled) | ||
# case_4.js - Unnecessary function calls: | ||
before x 8,372,334 ops/sec ±0.49% (90 runs sampled) | ||
after x 853,523,303 ops/sec ±0.23% (92 runs sampled) | ||
before - classnames x 4,771,703 ops/sec ±0.40% (92 runs sampled) | ||
before - clsx x 8,444,230 ops/sec ±0.32% (89 runs sampled) | ||
after - N/A x 842,537,779 ops/sec ±0.26% (89 runs sampled) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
const clsx = require('clsx'); | ||
|
||
module.exports = [ | ||
'String literals', | ||
() => { | ||
module.exports = { | ||
title: 'Object with string literals', | ||
before(clsx) { | ||
return clsx({ | ||
btn: true, | ||
'col-md-1': true, | ||
['btn-primary']: true, | ||
}); | ||
}, | ||
() => { | ||
after() { | ||
return 'btn col-md-1 btn-primary'; | ||
}, | ||
]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
const clsx = require('clsx'); | ||
|
||
const isDisabled = true; | ||
|
||
module.exports = [ | ||
'Unnecessary function calls', | ||
() => { | ||
module.exports = { | ||
title: 'Unnecessary function calls', | ||
before(clsx) { | ||
return clsx({ | ||
btn: true, | ||
'btn-foo': isDisabled, | ||
'btn-bar': !isDisabled, | ||
}); | ||
}, | ||
() => { | ||
after() { | ||
return 'btn ' + (isDisabled ? 'btn-foo' : 'btn-bar'); | ||
}, | ||
]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters