This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from atom/mb-onig-string-properties
Add some convenience APIs to OnigString
- Loading branch information
Showing
14 changed files
with
582 additions
and
525 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 |
---|---|---|
|
@@ -12,10 +12,7 @@ addons: | |
- g++-4.8 | ||
|
||
node_js: | ||
- "iojs" | ||
- "node" | ||
- "0.10" | ||
- "0.12" | ||
|
||
install: | ||
- export CXX=g++-4.8 | ||
|
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs') | ||
const path = require('path') | ||
const {OnigScanner} = require('..') | ||
|
||
function runBenchmarkSync (lines, scanner) { | ||
let startTime = Date.now() | ||
let matches = 0 | ||
|
||
for (let row = 0, rowCount = lines.length; row < rowCount; row++) { | ||
const line = lines[row] | ||
for (let position = 0, length = line.length; position <= length; position++) { | ||
if (scanner.findNextMatchSync(line, position)) matches++ | ||
} | ||
} | ||
|
||
console.log(`sync: ${matches} matches in ${Date.now() - startTime}ms`) | ||
} | ||
|
||
function runBenchmarkAsync (lines, scanner) { | ||
let matches = 0 | ||
let callsInProgress = 0 | ||
|
||
function callback (error, match) { | ||
if (match != null) { matches++ } | ||
if (--callsInProgress === 0) { | ||
console.log(`async: ${matches} matches in ${Date.now() - startTime}ms`) | ||
} | ||
}; | ||
|
||
var startTime = Date.now() | ||
for (let row = 0, rowCount = lines.length; row < rowCount; row++) { | ||
const line = lines[row] | ||
for (let position = 0, length = line.length; position <= length; position++) { | ||
callsInProgress++ | ||
scanner.findNextMatch(line, position, callback) | ||
} | ||
} | ||
} | ||
|
||
console.log('oneline.js') | ||
runBenchmarkSync( | ||
fs.readFileSync(path.join(__dirname, 'oneline.js'), 'utf8').split('\n'), | ||
new OnigScanner(['\\[', '\\]', '\\{', '\\}']) | ||
) | ||
|
||
console.log('large.js') | ||
runBenchmarkSync( | ||
fs.readFileSync(path.join(__dirname, 'large.js'), 'utf8').split('\n'), | ||
new OnigScanner(['this', 'var', 'selector', 'window']) | ||
) | ||
|
||
runBenchmarkAsync( | ||
fs.readFileSync(path.join(__dirname, 'large.js'), 'utf8').split('\n'), | ||
new OnigScanner(['this', 'var', 'selector', 'window']) | ||
) |
This file was deleted.
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.