diff --git a/createWebpackConfig.js b/createWebpackConfig.js
index 582dae4..5d88ceb 100644
--- a/createWebpackConfig.js
+++ b/createWebpackConfig.js
@@ -6,6 +6,9 @@ module.exports = function createWebpackConfig(_options) {
var options = _options || {};
config = {
+ context: options.context,
+ entry: options.entry,
+
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
],
diff --git a/package.json b/package.json
index 7ae7e43..f8ab73d 100644
--- a/package.json
+++ b/package.json
@@ -20,7 +20,8 @@
],
"scripts": {
"test": "gulp",
- "prepublish": "gulp prepublish"
+ "prepublish": "gulp prepublish",
+ "perf-server": "`npm bin`/webpack-dev-server --config perf/webpack.config.js --hot"
},
"license": "MIT",
"bugs": {
@@ -33,9 +34,11 @@
"babel-core": "^5.5.0",
"babel-eslint": "^4.0.5",
"babel-loader": "^5.3.2",
+ "benchmark": "^1.0.0",
"chai": "^3.2.0",
"eslint": "^0.24.1",
"eslint-config-airbnb": "0.0.7",
+ "exports-loader": "^0.6.2",
"gulp": "^3.6.0",
"gulp-babel": "^5.1.0",
"gulp-eslint": "^0.15.0",
@@ -54,6 +57,7 @@
"phantomjs": "^1.9.17",
"rimraf": "^2.4.2",
"webpack": "^1.10.5",
+ "webpack-dev-server": "^1.10.1",
"webpack-stream": "^2.1.0"
}
}
diff --git a/perf/.eslintrc b/perf/.eslintrc
new file mode 100644
index 0000000..fa91c1b
--- /dev/null
+++ b/perf/.eslintrc
@@ -0,0 +1,10 @@
+{
+ "extends": "../.eslintrc",
+ "rules": {
+ "new-cap": [2, {
+ "capIsNewExceptions": [
+ "Suite"
+ ]
+ }],
+ }
+}
diff --git a/perf/index.html b/perf/index.html
new file mode 100644
index 0000000..b45cc04
--- /dev/null
+++ b/perf/index.html
@@ -0,0 +1,14 @@
+
+
+
+ updeep perf
+
+
+
+
+ Running tests...
+
+
+ Done!
+
+
diff --git a/perf/index.js b/perf/index.js
new file mode 100644
index 0000000..12b496d
--- /dev/null
+++ b/perf/index.js
@@ -0,0 +1,46 @@
+const Benchmark = require('benchmark');
+
+const u = require('../lib');
+const _ = require('lodash');
+
+const suite = Benchmark.Suite(); // eslint-disable
+
+const add = (x, y) => x + y;
+const fakeCurryAdd = x => y => x + y;
+const curryAdd = _.curry(add);
+
+const array = [0, 1, 2, 3, 4, 5];
+
+suite
+ .add('regular function call', () => {
+ add(3, 4);
+ })
+ .add('fake curry', () => {
+ fakeCurryAdd(3)(4);
+ })
+ .add('curry full call', () => {
+ curryAdd(3, 4);
+ })
+ .add('curry partial call', () => {
+ curryAdd(3)(4);
+ })
+ .add('_.map', () => {
+ _.map(array, curryAdd(8));
+ })
+ .add('u.map', () => {
+ u.map(curryAdd(8), array);
+ })
+ .add('_.map no changes', () => {
+ _.map(array, x => x);
+ })
+ .add('u.map no changes', () => {
+ u.map(x => x, array);
+ })
+
+ .on('cycle', (event) => {
+ if (typeof document !== 'undefined') {
+ const el = document.getElementById('perf');
+ el.innerHTML = el.innerHTML + String(event.target) + '
';
+ }
+ })
+ .run({ async: true });
diff --git a/perf/webpack.config.js b/perf/webpack.config.js
new file mode 100644
index 0000000..94f0868
--- /dev/null
+++ b/perf/webpack.config.js
@@ -0,0 +1,32 @@
+'use strict'; /* eslint strict:0, no-var:0, func-names:0 */
+
+var path = require('path');
+
+var config = require('../createWebpackConfig')({
+ context: __dirname,
+ entry: [
+ 'webpack/hot/dev-server',
+ './index.js',
+ ],
+ minify: false,
+ env: 'production',
+});
+
+config.output = {
+ path: path.join(__dirname, './build'),
+ publicPath: '/assets/',
+ filename: 'perf.js',
+};
+
+config.devServer = {
+ contentBase: __dirname,
+ noInfo: true,
+ hot: true,
+ inline: true,
+};
+
+config.module.noParse = [
+ /benchmark\.js$/,
+];
+
+module.exports = config;