Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 36.4k
src: replace naive search with naive + BMH in Buffer::IndexOf#2539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| var common = require('../common.js'); | ||
| var fs = require('fs'); | ||
| var bench = common.createBenchmark(main, { | ||
| search: ['@', 'SQ', '10x', '--l', 'Alice', 'Gryphon', 'Panther', | ||
| 'Ou est ma chatte?', 'found it very', 'among mad people', | ||
| 'neighbouring pool', 'Soo--oop', 'aaaaaaaaaaaaaaaaa', | ||
| 'venture to go near the house till she had brought herself down to', | ||
| '</i> to the Caterpillar'], | ||
| encoding: ['undefined', 'utf8', 'ucs2', 'binary'], | ||
| type: ['buffer', 'string'], | ||
| iter: [1] | ||
| }); | ||
| function main(conf) { | ||
| var iter = (conf.iter) * 100000; | ||
| var aliceBuffer = fs.readFileSync(__dirname + '/../fixtures/alice.html'); | ||
| var search = conf.search; | ||
| var encoding = conf.encoding; | ||
| if (encoding === 'undefined') { | ||
| encoding = undefined; | ||
| } | ||
| if (encoding === 'ucs2') { | ||
| aliceBuffer = new Buffer(aliceBuffer.toString(), encoding); | ||
| } | ||
| if (conf.type === 'buffer') { | ||
| search = new Buffer(new Buffer(search).toString(), encoding); | ||
| } | ||
| bench.start(); | ||
| for (var i = 0; i < iter; i++) { | ||
| aliceBuffer.indexOf(search, 0, encoding); | ||
| } | ||
| bench.end(iter); | ||
| } |
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #include "string_search.h" | ||
| namespace node { | ||
| namespace stringsearch { | ||
| int StringSearchBase::kBadCharShiftTable[kUC16AlphabetSize]; | ||
| int StringSearchBase::kGoodSuffixShiftTable[kBMMaxShift + 1]; | ||
| int StringSearchBase::kSuffixTable[kBMMaxShift + 1]; | ||
| } | ||
| } // namespace node::stringsearch |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a concern if user does this on an odd length buffer?