Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Fuzzy search with fuzzysearch | Vanilla - Ramda - Lodash
Fuzzy search with fuzzysearch (https://github.com/bevacqua/fuzzysearch) using filter and reduce with Vanilla, Ramda, and Lodash.
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Browser:
Chrome 122
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Vanilla filter
63.5 Ops/sec
Vanilla reduce
65.4 Ops/sec
Ramda filter
67.6 Ops/sec
Ramda reduce
65.4 Ops/sec
Lodash filter
65.1 Ops/sec
Lodash reduce
68.2 Ops/sec
HTML Preparation code:
<script src="//unpkg.com/ramda@0.26.1/dist/ramda.min.js"></script> <script src="//cdn.jsdelivr.net/npm/lodash@4.17.15/lodash.min.js"></script>
Script Preparation code:
function fuzzysearch (needle, haystack) { var hlen = haystack.length; var nlen = needle.length; if (nlen > hlen) { return false; } if (nlen === hlen) { return needle === haystack; } outer: for (var i = 0, j = 0; i < nlen; i++) { var nch = needle.charCodeAt(i); while (j < hlen) { if (haystack.charCodeAt(j++) === nch) { continue outer; } } return false; } return true; } var letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] var getPositions = l => { let positions = [] for (let i = 0; i < l; i++) { let position = Math.floor(Math.random() * 26 + 1) positions.push(position) } return positions } var wordLength = () => Math.floor(Math.random() * 15 + 5) var createWord = ps => ps.map(p => letters[p]).join('') var getWords = l => { let words = [] for (let i = 0; i < l; i++) { let positions = getPositions(wordLength()) let word = createWord(positions) words.push(word) } return words } var reducer = (a, c) => { if (fuzzysearch(term, c)) { a.push(c) } return a } var filtering = w => fuzzysearch(term, w) var words = getWords(100000) var term = 'omg'
Tests:
Vanilla filter
words.filter(filtering)
Vanilla reduce
words.reduce(reducer, [])
Ramda filter
R.filter(filtering, words)
Ramda reduce
R.reduce(reducer, [], words)
Lodash filter
_.filter(words, filtering)
Lodash reduce
_.reduce(words, reducer, [])