-
Notifications
You must be signed in to change notification settings - Fork 22
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
1 parent
b875435
commit de0c7fe
Showing
10 changed files
with
90 additions
and
102 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
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,28 +1,21 @@ | ||
const benchmark = require("benchmark") | ||
const classnames = require("classnames") | ||
const classwrap = require("../") | ||
const { Suite } = require("benchmark") | ||
const cx = require("classnames") | ||
const cc = require("../") | ||
|
||
require("./fixtures").map(fixed => { | ||
const suite = new benchmark.Suite() | ||
|
||
suite.add(`classwrap – ${fixed.description}`, () => { | ||
classwrap.apply({}, fixed.args) | ||
}) | ||
|
||
suite.add(`classnames – ${fixed.description}`, () => { | ||
classnames.apply({}, fixed.args) | ||
}) | ||
|
||
suite.on("cycle", event => console.log(event.target + "")) | ||
|
||
suite.on("complete", function() { | ||
console.log(`\nFastest is ${this.filter("fastest").pluck("name")} \n`) | ||
}) | ||
|
||
suite.on("error", ({ target }) => { | ||
console.log(target.error.message) | ||
throw target.error | ||
}) | ||
|
||
suite.run() | ||
require("./fixtures").map((fixed, index, { length }) => { | ||
const suite = new Suite() | ||
suite | ||
.add(`Classcat – ${fixed.description}`, () => cc.apply({}, fixed.args)) | ||
.add(`classNames – ${fixed.description}`, () => cx.apply({}, fixed.args)) | ||
.on("cycle", ({ target: { name, hz, stats } }) => | ||
console.log(`${name} × ${Math.floor(hz).toLocaleString()} ops/sec`) | ||
) | ||
.on("complete", function() { | ||
console.log( | ||
`Fastest is ${this.filter("fastest").map("name")}${index + 1 < length | ||
? "\n" | ||
: ""}` | ||
) | ||
}) | ||
.run() | ||
}) |
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,14 +1,14 @@ | ||
{ | ||
"name": "classwrap-benchmarks", | ||
"name": "classcat-benchmarks", | ||
"version": "1.0.0", | ||
"private": true, | ||
"description": "Classwrap vs JedWatson/classnames benchmarks.", | ||
"description": "Classcat vs JedWatson/classnames benchmarks.", | ||
"main": "index.js", | ||
"scripts": {}, | ||
"author": "Jorge Bucaran", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"benchmark": "^2.1.4", | ||
"classnames": "2.2.5" | ||
"classnames": "*" | ||
} | ||
} |
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
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