Skip to content
Open
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
4 changes: 3 additions & 1 deletion src/assoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ module.exports = ({ object }) => {
.add('lodash/fp (String)' , () => { fp.set(prop, 42, value); })
.add('lodash/fp (Array)' , () => { fp.set([prop], 42, value); })
// .add('mori.assoc' , () => { mori.assoc(moriVal, path, 42); })
.add('ramda' , () => { R.assoc(prop, 42, value); });
.add('ramda' , () => { R.assoc(prop, 42, value); })
.add('vanilla' , () => { Object.assign({}, value, { [prop]: 42 });
});
}
3 changes: 2 additions & 1 deletion src/assocPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ module.exports = ({ object }) => {
return suite
.add('immutable', () => { immVal.setIn(path, 42); })
.add('ramda', () => { R.assocPath(path, 42, value); })
.add('lodash', () => { _.update(pathStr, 42, value); });
.add('lodash', () => { _.update(pathStr, 42, value); })
.add('vanilla', () => { Object.assign({}, value, {[pathStr]:42})});
}
3 changes: 3 additions & 0 deletions src/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ module.exports = ({ list }) => {
})
.add('lodash', function () {
_.find(pred, value);
})
.add('vanilla', function() {
value.find(pred);
});
};
6 changes: 6 additions & 0 deletions src/mapFilterReduce.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,11 @@ module.exports = ({ list }) => {
R.filter(even),
R.map(inc)
)(value);
})
.add('vanilla', () => {
value
.map(inc)
.filter(even)
.reduce(add, 0)
});
}
17 changes: 14 additions & 3 deletions src/mapIncAndReverse.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const suite = new Benchmark.Suite('mapIncAndReverse');
module.exports = ({ object }) => {
const { value } = object;
const immVal = I.fromJS(value);

return suite
.add('lodash.chain().map(inc).reverse()', () => {
_.chain(value)
Expand All @@ -23,15 +24,25 @@ module.exports = ({ object }) => {
)(value);
})
.add('lodash/fp.compose(reverse, map(inc))', () => {
fp.compose(
const ans = fp.compose(
fp.reverse,
fp.map(fp.inc)
)(value);
})
.add('vanilla', () => {
const obj = Object.assign({}, value);
const inc = k => obj[k]+=1;
Object
.keys(obj) // no object.values yet - stage-4 till May?
.map(inc)
.reverse();
})
.add('ramda.compose(reverse, map(inc))', () => {
R.compose(
R.reverse,
R.map(R.inc)
R.map(R.inc),
R.values // almost twice as fast to convert to an array first
)(value);
});
})

}
5 changes: 3 additions & 2 deletions src/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ const suite = new Benchmark.Suite;

module.exports = ({ object }) => {
const { value, path, pathStr } = object;
console.log('path, pathStr', path, pathStr)
const immVal = I.fromJS(value);
return suite
.add('immutable', () => { immVal.getIn(path); })
.add('ramda' , () => { R.path(path, value); })
.add('lodash' , () => { _.get(pathStr, value); });

.add('lodash' , () => { _.get(pathStr, value); })
.add('vanilla' , () => { value[pathStr]; });
}