diff --git a/.eslintrc.js b/.eslintrc.js index e3020c5..4fe9bd5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -44,6 +44,15 @@ const config = { "no-unused-expressions": 0 } }, + { + files: ['perf/**/*'], + env: { + browser: true + }, + rules: { + 'no-unused-vars': 'off', + } + }, { files: ['**/*.@(ts|tsx)'], parser: '@typescript-eslint/parser', @@ -52,8 +61,6 @@ const config = { sourceType: 'module', }, rules: { - 'no-undef': 'off', - 'no-unused-vars': 'off', '@typescript-eslint/class-name-casing': 'error', '@typescript-eslint/consistent-type-assertions': 'error', '@typescript-eslint/no-empty-interface': 'error', diff --git a/perf/index.html b/perf/index.html new file mode 100644 index 0000000..7bf335a --- /dev/null +++ b/perf/index.html @@ -0,0 +1,14 @@ + + +
+Done!
+ + diff --git a/perf/index.js b/perf/index.js new file mode 100644 index 0000000..5a45426 --- /dev/null +++ b/perf/index.js @@ -0,0 +1,85 @@ +const Benchmark = require('benchmark') + +const _ = require('lodash') +const u = require('../lib') +const { curry2, curry4 } = require('../lib/util/curry') + +const add4 = (a, b, c, d) => a + b + c + d +const add2 = (a, b) => a + b +const fakeCurryAdd = (x) => (y) => x + y +const lodashCurryAdd2 = _.curry(add2) +const updeepCurryAdd2 = curry2(add2) +const lodashCurryAdd4 = _.curry(add4) +const updeepCurryAdd4 = curry4(add4) +// const updeepCurryBig = curry.curryBig(add); + +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 + } +} + +function createSuite(suiteName, tests) { + const suite = Benchmark.Suite() // eslint-disable + + return () => { + log(`