-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45313f4
commit 2ffaffc
Showing
3 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const bench = require('nanobench') | ||
const createSearch = require('./') | ||
let count = 1000 | ||
const largeArray = [] | ||
const hashes = { 1: 'foo', 2: 'foo bar', 3: 'hello', 4: 'world', 5: 'baz qux' } | ||
while (count--) largeArray.push(`aaaaaaaaaaaaaaaaaaa${hashes[count] || ''}`) | ||
|
||
bench('instantiate 1000000 times', function (b) { | ||
b.start() | ||
|
||
for (let i = 0; i < 1000000; i++) { | ||
createSearch(largeArray) | ||
} | ||
|
||
b.end() | ||
}) | ||
|
||
const search = createSearch(largeArray) | ||
bench('search 10000 times', function (b) { | ||
b.start() | ||
|
||
for (let i = 0; i < 10000; i++) { | ||
search('foo bar baz qux') | ||
} | ||
|
||
b.end() | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters