Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

soundex benchmarks

  • Loading branch information...
commit 9780bf4c9e325ba0d6ad57f666d7e6a0f72976f1 1 parent 88ed70f
@tj tj authored
View
32 benchmarks/index.js
@@ -0,0 +1,32 @@
+
+/**
+ * Module dependencies.
+ */
+
+var uubench = require('uubench')
+ , natural = require('../');
+
+fs = require('fs');
+metaphone = natural.Metaphone.process;
+soundex = natural.SoundEx.process;
+
+suite = new uubench.Suite({
+ start: function(){
+ console.log();
+ },
+
+ result: function(name, stats){
+ var persec = 1000 / stats.elapsed
+ , ops = stats.iterations * persec;
+ console.log(' \033[90m%s : \033[36m%s \033[90mops/s\033[0m', name, ops | 0);
+ },
+
+ done: function(){
+ console.log();
+ }
+});
+
+require('./metaphone');
+require('./soundex');
+
+suite.run();
View
29 benchmarks.js → benchmarks/metaphone.js
@@ -1,29 +1,4 @@
-/**
- * Module dependencies.
- */
-
-var uubench = require('uubench')
- , natural = require('./')
- , metaphone = natural.Metaphone.process
- , fs = require('fs');
-
-var suite = new uubench.Suite({
- start: function(){
- console.log();
- },
-
- result: function(name, stats){
- var persec = 1000 / stats.elapsed
- , ops = stats.iterations * persec;
- console.log(' \033[90m%s : \033[36m%s \033[90mops/s\033[0m', name, ops | 0);
- },
-
- done: function(){
- console.log();
- }
-});
-
// single word
suite.bench('metaphone() word', function(next){
@@ -49,6 +24,4 @@ suite.bench('metaphone() medium', function(next){
metaphone(words2[i]);
}
next();
-});
-
-suite.run();
+});
View
27 benchmarks/soundex.js
@@ -0,0 +1,27 @@
+
+// single word
+
+suite.bench('soundex() word', function(next){
+ soundex('stephen');
+ next();
+});
+
+// small body of text
+
+var words = fs.readFileSync('lib/natural/index.js', 'utf8').split(/\W+/);
+suite.bench('soundex() small', function(next){
+ for (var i = 0, len = words.length; i < len; ++i) {
+ soundex(words[i]);
+ }
+ next();
+});
+
+// medium body of text
+
+var words2 = fs.readFileSync('README.md', 'utf8').split(/\W+/);
+suite.bench('soundex() medium', function(next){
+ for (var i = 0, len = words2.length; i < len; ++i) {
+ soundex(words2[i]);
+ }
+ next();
+});
Please sign in to comment.
Something went wrong with that request. Please try again.