Skip to content

Commit 6caa90e

Browse files
authored
Move benchmarks into dedicated NPM workspace (#329)
1 parent 609386e commit 6caa90e

File tree

7 files changed

+199
-2705
lines changed

7 files changed

+199
-2705
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ performance.
1212
[JSPerf](http://jsperf.com) test and link to it from your issue / PR.
1313
* Tests must be added for any change or new feature before it will be accepted.
1414

15-
A benchmark utilitiy is included so that changes may be tested against the
16-
current published version. To run the benchmarks, `npm install` in the
17-
`./benchmarks` directory then run `npm run benchmarks` in the package root.
15+
A benchmark utility is included so that changes may be tested against the
16+
current published version. To run the benchmarks, run `npm install` in the
17+
root directory then run `npm run benchmarks` in the `./benchmarks` directory.
1818

1919
Please be aware though that local benchmarks are just a smoke-signal; they will
20-
run in the v8 version that your node/iojs uses, while classNames is _most_
20+
run in the v8 version that your local Node.js uses, while classNames is _most_
2121
often run across a wide variety of browsers and browser versions.
22+
23+
It is recommended to test possible regressions in performance in all major
24+
browsers. This can be done by running `npm run benchmarks-browserify` in the
25+
`./benchmarks` directory.

benchmarks/package-lock.json

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

benchmarks/package.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
{
22
"name": "classnames-benchmarks",
3-
"version": "1.0.0",
4-
"private": true,
5-
"description": "",
6-
"main": "run.js",
73
"scripts": {
8-
"test": "echo \"Tests should be run in the main classnames package.\" && exit 1"
4+
"benchmarks": "node ./run.js",
5+
"benchmarks-browserify": "browserify ./runInBrowser.js >./runInBrowser.bundle.js"
96
},
10-
"author": "Jed Watson",
11-
"license": "MIT",
127
"devDependencies": {
13-
"benchmark": "2.1.4",
14-
"classnames": "*"
8+
"benchmark": "^2.1.4",
9+
"browserify": "^17.0.0",
10+
"classnames-npm": "npm:classnames@*",
11+
"classnames-local": "file:../"
1512
}
1613
}

benchmarks/run.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
var fixtures = require('./fixtures');
2-
var local = require('../');
3-
var dedupe = require('../dedupe');
4-
var localPackage = require('../package.json');
2+
var local = require('classnames-local');
3+
var dedupe = require('classnames-local/dedupe');
4+
var localPackage = require('classnames-local/package.json');
55

66
function log (message) {
77
console.log(message);
88
}
99

1010
try {
11-
var npm = require('classnames');
12-
var npmDedupe = require('classnames/dedupe');
13-
var npmPackage = require('./node_modules/classnames/package.json');
11+
var npm = require('classnames-npm');
12+
var npmDedupe = require('classnames-npm/dedupe');
13+
var npmPackage = require('classnames-npm/package.json');
1414
} catch (e) {
1515
log('There was an error loading the benchmark classnames package.\n' +
1616
'Please make sure you have run `npm install` in ./benchmarks\n');
@@ -19,7 +19,7 @@ try {
1919

2020
if (localPackage.version !== npmPackage.version) {
2121
log('Your local version (' + localPackage.version + ') does not match the installed version (' + npmPackage.version + ')\n\n' +
22-
'Please run `npm update` in ./benchmarks to ensure you are benchmarking\n' +
22+
'Please run `npm update classnames-npm` in ./benchmarks to ensure you are benchmarking\n' +
2323
'the latest version of this package.\n');
2424
process.exit(0);
2525
}

benchmarks/runInBrowser.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
var fixtures = require('./fixtures');
2-
var local = require('../');
3-
var dedupe = require('../dedupe');
4-
var localPackage = require('../package.json');
2+
var local = require('classnames-local');
3+
var dedupe = require('classnames-local/dedupe');
4+
var localPackage = require('classnames-local/package.json');
55

6-
var npm = require('classnames');
7-
var npmDedupe = require('classnames/dedupe');
8-
var npmPackage = require('./node_modules/classnames/package.json');
6+
var npm = require('classnames-npm');
7+
var npmDedupe = require('classnames-npm/dedupe');
8+
var npmPackage = require('classnames-npm/package.json');
99

1010
function log (message) {
1111
console.log(message);
@@ -16,7 +16,7 @@ function log (message) {
1616

1717
if (localPackage.version !== npmPackage.version) {
1818
log('Your local version (' + localPackage.version + ') does not match the installed version (' + npmPackage.version + ')\n\n' +
19-
'Please run `npm update` in ./benchmarks to ensure you are benchmarking\n' +
19+
'Please run `npm update classnames-npm` in ./benchmarks to ensure you are benchmarking\n' +
2020
'the latest version of this package.\n');
2121
return;
2222
}

0 commit comments

Comments
 (0)