Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add new benchmarks

  • Loading branch information...
commit 2025521a444968eac25612f404ee8d6683f5d6fe 1 parent 3f01fcf
TJ Holowaychuk authored

Showing 3 changed files with 46 additions and 83 deletions. Show diff stats Hide diff stats

  1. +3 3 Makefile
  2. +18 55 benchmarks/index.js
  3. +25 25 package.json
6 Makefile
@@ -2,7 +2,7 @@
2 2 test:
3 3 @node test
4 4
5   -benchmark:
6   - @node benchmarks
  5 +bench:
  6 + @./node_modules/.bin/matcha benchmarks
7 7
8   -.PHONY: test benchmark
  8 +.PHONY: test bench
73 benchmarks/index.js
@@ -3,43 +3,10 @@
3 3 * Module dependencies.
4 4 */
5 5
6   -var uubench = require('uubench')
7   - , reds = require('../').createSearch('reds')
8   - , fs = require('fs');
  6 +var reds = require('../').createSearch('reds');
  7 +var fs = require('fs');
9 8
10   -/**
11   - * Pad the given string.
12   - */
13   -
14   -function pad(str, width) {
15   - return Array(width - str.length + 1).join(' ') + str;
16   -}
17   -
18   -/**
19   - * Global suite.
20   - */
21   -
22   -suite = new uubench.Suite({
23   - start: function(){
24   - console.log();
25   - },
26   -
27   - result: function(name, stats){
28   - var persec = 1000 / stats.elapsed
29   - , ops = stats.iterations * persec;
30   - console.log(' \033[90m%s : \033[36m%s \033[90mops/s\033[0m'
31   - , pad(name, 20)
32   - , ops | 0);
33   - },
34   -
35   - done: function(){
36   - console.log();
37   - }
38   -});
39   -
40   -/**
41   - * Text bodies.
42   - */
  9 +// test data
43 10
44 11 var tiny = fs.readFileSync('package.json', 'utf8');
45 12 tiny = Array(5).join(tiny);
@@ -47,26 +14,22 @@ var small = fs.readFileSync('Readme.md', 'utf8');
47 14 var medium = Array(10).join(small);
48 15 var large = Array(30).join(medium);
49 16
50   -console.log();
51   -console.log(' tiny: %dkb', (tiny.length / 1024).toFixed(2));
52   -console.log(' small: %dkb', (small.length / 1024).toFixed(2));
53   -console.log(' medium: %dkb', (medium.length / 1024).toFixed(2));
54   -console.log(' large: %dmb', (large.length / 1024 / 1024).toFixed(2));
55   -
56   -suite.bench('index() tiny', function(next){
57   - reds.index(tiny, 0, next);
58   -});
  17 +// benchmarks
59 18
60   -// suite.bench('index() small', function(next){
61   -// reds.index(small, 0, next);
62   -// });
  19 +suite('indexing', function(){
  20 + bench('tiny', function(done){
  21 + reds.index(tiny, '1234', done);
  22 + });
63 23
64   -// suite.bench('index() medium', function(next){
65   -// reds.index(medium, 1, next);
66   -// });
  24 + bench('small', function(done){
  25 + reds.index(small, '1234', done);
  26 + });
67 27
68   -// suite.bench('index() large', function(next){
69   -// reds.index(large, 2, next);
70   -// });
  28 + bench('medium', function(done){
  29 + reds.index(medium, '1234', done);
  30 + });
71 31
72   -suite.run();
  32 + bench('large', function(done){
  33 + reds.index(large, '1234', done);
  34 + });
  35 +});
50 package.json
... ... @@ -1,27 +1,27 @@
1 1 {
2   - "name": "reds",
3   - "version": "0.2.4",
4   - "description": "Redis search for node.js",
5   - "keywords": [
6   - "redis",
7   - "search",
8   - "metaphone",
9   - "phonetics",
10   - "natural"
11   - ],
12   - "author": "TJ Holowaychuk <tj@vision-media.ca>",
13   - "dependencies": {
14   - "natural": "0.1.17",
15   - "redis": "0.7.2"
16   - },
17   - "devDependencies": {
18   - "should": "*",
19   - "uubench": "*",
20   - "superagent": "*"
21   - },
22   - "main": "index",
23   - "repository": {
24   - "type": "git",
25   - "url": "https://github.com/visionmedia/reds.git"
26   - }
  2 + "name": "reds",
  3 + "version": "0.2.4",
  4 + "description": "Redis search for node.js",
  5 + "keywords": [
  6 + "redis",
  7 + "search",
  8 + "metaphone",
  9 + "phonetics",
  10 + "natural"
  11 + ],
  12 + "author": "TJ Holowaychuk <tj@vision-media.ca>",
  13 + "dependencies": {
  14 + "natural": "0.1.17",
  15 + "redis": "0.7.2"
  16 + },
  17 + "devDependencies": {
  18 + "should": "*",
  19 + "superagent": "*",
  20 + "matcha": "~0.5.0"
  21 + },
  22 + "main": "index",
  23 + "repository": {
  24 + "type": "git",
  25 + "url": "https://github.com/visionmedia/reds.git"
  26 + }
27 27 }

0 comments on commit 2025521

Please sign in to comment.
Something went wrong with that request. Please try again.