Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move benchmarks into dedicated NPM workspace #329

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ performance.
[JSPerf](http://jsperf.com) test and link to it from your issue / PR.
* Tests must be added for any change or new feature before it will be accepted.

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

Please be aware though that local benchmarks are just a smoke-signal; they will
run in the v8 version that your node/iojs uses, while classNames is _most_
run in the v8 version that your local Node.js uses, while classNames is _most_
often run across a wide variety of browsers and browser versions.

It is recommended to test possible regressions in performance in all major
browsers. This can be done by running `npm run benchmarks-browserify` in the
`./benchmarks` directory.
75 changes: 0 additions & 75 deletions benchmarks/package-lock.json

This file was deleted.

15 changes: 6 additions & 9 deletions benchmarks/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
{
"name": "classnames-benchmarks",
"version": "1.0.0",
"private": true,
"description": "",
"main": "run.js",
"scripts": {
"test": "echo \"Tests should be run in the main classnames package.\" && exit 1"
"benchmarks": "node ./run.js",
"benchmarks-browserify": "browserify ./runInBrowser.js >./runInBrowser.bundle.js"
},
"author": "Jed Watson",
"license": "MIT",
"devDependencies": {
"benchmark": "2.1.4",
"classnames": "*"
"benchmark": "^2.1.4",
"browserify": "^17.0.0",
"classnames-npm": "npm:classnames@*",
"classnames-local": "file:../"
}
}
14 changes: 7 additions & 7 deletions benchmarks/run.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
var fixtures = require('./fixtures');
var local = require('../');
var dedupe = require('../dedupe');
var localPackage = require('../package.json');
var local = require('classnames-local');
var dedupe = require('classnames-local/dedupe');
var localPackage = require('classnames-local/package.json');

function log (message) {
console.log(message);
}

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

if (localPackage.version !== npmPackage.version) {
log('Your local version (' + localPackage.version + ') does not match the installed version (' + npmPackage.version + ')\n\n' +
'Please run `npm update` in ./benchmarks to ensure you are benchmarking\n' +
'Please run `npm update classnames-npm` in ./benchmarks to ensure you are benchmarking\n' +
'the latest version of this package.\n');
process.exit(0);
}
Expand Down
14 changes: 7 additions & 7 deletions benchmarks/runInBrowser.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var fixtures = require('./fixtures');
var local = require('../');
var dedupe = require('../dedupe');
var localPackage = require('../package.json');
var local = require('classnames-local');
var dedupe = require('classnames-local/dedupe');
var localPackage = require('classnames-local/package.json');

var npm = require('classnames');
var npmDedupe = require('classnames/dedupe');
var npmPackage = require('./node_modules/classnames/package.json');
var npm = require('classnames-npm');
var npmDedupe = require('classnames-npm/dedupe');
var npmPackage = require('classnames-npm/package.json');

function log (message) {
console.log(message);
Expand All @@ -16,7 +16,7 @@ function log (message) {

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