diff --git a/.eslintrc.js b/.eslintrc.js index 4fe9bd5..4f0a77b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -41,16 +41,7 @@ const config = { sourceType: 'module', }, rules: { - "no-unused-expressions": 0 - } - }, - { - files: ['perf/**/*'], - env: { - browser: true - }, - rules: { - 'no-unused-vars': 'off', + "no-unused-expressions": 'off' } }, { diff --git a/package.json b/package.json index 7e57f50..962e525 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "url": "https://github.com/substantial/updeep/issues" }, "scripts": { + "benchmark": "NODE_ENV=production node --require \"@babel/register\" perf", "build": "microbundle", "dev": "microbundle watch", "dtslint": "dtslint --localTs node_modules/typescript/lib types", @@ -51,6 +52,7 @@ "@typescript-eslint/parser": "^2.26.0", "benchmark": "^2.1.4", "chai": "^4.2.0", + "chalk": "^4.0.0", "dtslint": "^3.4.1", "eslint": "^6.8.0", "eslint-config-prettier": "^6.10.1", @@ -62,6 +64,7 @@ "microbundle": "^0.11.0", "mocha": "^7.0.0", "prettier": "^2.0.2", + "table": "^5.4.6", "typescript": "^3.6.3" } } diff --git a/perf/.eslintrc.js b/perf/.eslintrc.js new file mode 100644 index 0000000..5f2e52e --- /dev/null +++ b/perf/.eslintrc.js @@ -0,0 +1,14 @@ +module.exports = { + extends: require.resolve("../.eslintrc.js"), + env: { + node: true, + es6: true, + }, + parserOptions: { + sourceType: 'module', + }, + rules: { + 'no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': 'off' + } +} diff --git a/perf/index.html b/perf/index.html deleted file mode 100644 index 7bf335a..0000000 --- a/perf/index.html +++ /dev/null @@ -1,14 +0,0 @@ - - -
-Done!
- - diff --git a/perf/index.js b/perf/index.js index 5a45426..c88ea50 100644 --- a/perf/index.js +++ b/perf/index.js @@ -1,8 +1,10 @@ -const Benchmark = require('benchmark') +import Benchmark from 'benchmark' +import {table} from 'table' +import chalk from 'chalk' -const _ = require('lodash') -const u = require('../lib') -const { curry2, curry4 } = require('../lib/util/curry') +import _ from 'lodash' +import u from '../dist/index.umd.js' +import {curry2, curry4 } from '../lib/util/curry' const add4 = (a, b, c, d) => a + b + c + d const add2 = (a, b) => a + b @@ -16,33 +18,31 @@ const updeepCurryAdd4 = curry4(add4) const array = [0, 1, 2, 3, 4, 5] // const doUpdate = u(x => x + 1); -function log(str) { - if (typeof document !== 'undefined') { - console.log(str) - const el = document.getElementById('perf') - el.innerHTML += str - } -} + +const log = console.log function createSuite(suiteName, tests) { - const suite = Benchmark.Suite() // eslint-disable + const results = [] - return () => { - log(`