Skip to content

Commit

Permalink
Added small / medium benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jul 26, 2011
1 parent 6f5d125 commit 88ed70f
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions benchmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

var uubench = require('uubench')
, natural = require('./')
, metaphone = natural.Metaphone.process;
, metaphone = natural.Metaphone.process
, fs = require('fs');

var suite = new uubench.Suite({
start: function(){
Expand All @@ -23,9 +24,31 @@ var suite = new uubench.Suite({
}
});

suite.bench('metaphone()', function(next){
// single word

suite.bench('metaphone() word', function(next){
metaphone('stephen');
next();
});

// small body of text

var words = fs.readFileSync('lib/natural/index.js', 'utf8').split(/\W+/);
suite.bench('metaphone() small', function(next){
for (var i = 0, len = words.length; i < len; ++i) {
metaphone(words[i]);
}
next();
});

// medium body of text

var words2 = fs.readFileSync('README.md', 'utf8').split(/\W+/);
suite.bench('metaphone() medium', function(next){
for (var i = 0, len = words2.length; i < len; ++i) {
metaphone(words2[i]);
}
next();
});

suite.run();

0 comments on commit 88ed70f

Please sign in to comment.