Skip to content

Commit

Permalink
tab to spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Llamas committed Dec 29, 2013
1 parent 71cabf9 commit 5602781
Show file tree
Hide file tree
Showing 26 changed files with 1,311 additions and 0 deletions.
39 changes: 39 additions & 0 deletions examples/alphanum.js
@@ -0,0 +1,39 @@
"use strict";

var speedy = require ("../lib");

var code = "z".charCodeAt (0);
var re = /[a-z0-9]/i;

speedy.run ({
ascii: function (){
(code >= 48 && code <= 57) || (code >= 65 && code <= 90) ||
(code >= 97 && code <= 122);
},
regexp: function (){
re.test ("z");
}
});

/*
File: alphanum.js
Node v0.10.20
V8 v3.14.5.9
Speedy v0.1.0
Tests: 2
Timeout: 1000ms (1s 0ms)
Samples: 3
Total time per test: ~3000ms (3s 0ms)
Total time: ~6000ms (6s 0ms)
Higher is better (ops/sec)
ascii
158,806,860 ± 0.2%
regexp
28,731,896 ± 0.0%
Elapsed time: 6054ms (6s 54ms)
*/
35 changes: 35 additions & 0 deletions examples/array-creation.js
@@ -0,0 +1,35 @@
"use strict";

var speedy = require ("../lib");

speedy.run ({
literal: function (){
return [];
},
constructor: function (){
return new Array ();
}
});

/*
File: array-creation.js
Node v0.10.20
V8 v3.14.5.9
Speedy v0.1.0
Tests: 2
Timeout: 1000ms (1s 0ms)
Samples: 3
Total time per test: ~3000ms (3s 0ms)
Total time: ~6000ms (6s 0ms)
Higher is better (ops/sec)
literal
132,550,266 ± 0.0%
constructor
77,587,140 ± 0.0%
Elapsed time: 6054ms (6s 54ms)
*/
87 changes: 87 additions & 0 deletions examples/array-population.js
@@ -0,0 +1,87 @@
"use strict";

var speedy = require ("../lib");

var a1 = [], i1 = 0;
var a2 = [], i2 = 0;
var a3 = [], i3 = 0;
var n = 100;

speedy.run ({
push: function (){
if (i1 === n){
a1 = [];
i1 = 0;
}
i1++;
a1.push (1);
},
length: function (){
if (i2 === n){
a2 = [];
i2 = 0;
}
i2++;
a2[a2.length] = 1;
},
index: function (){
if (i3 === n){
a3 = [];
i3 = 0;
}
a3[i3++] = 1;
}
});

/*
The results vary depending on the array length
File: array-population.js
Node v0.10.20
V8 v3.14.5.9
Speedy v0.1.0
Tests: 3
Timeout: 1000ms (1s 0ms)
Samples: 3
Total time per test: ~3000ms (3s 0ms)
Total time: ~9000ms (9s 0ms)
Higher is better (ops/sec)
n = 100
push
82,890,473 ± 0.0%
length
52,293,355 ± 0.1%
index
52,790,295 ± 0.0%
n = 10000
push
71,426,828 ± 0.0%
length
70,783,269 ± 0.2%
index
72,458,042 ± 0.0%
n = 1000000
push
23,369,209 ± 0.6%
length
19,272,770 ± 0.0%
index
19,180,275 ± 0.3%
*/
40 changes: 40 additions & 0 deletions examples/bind.js
@@ -0,0 +1,40 @@
"use strict";

var speedy = require ("../lib");

var fn1 = function (){
this.a = 1;
}.bind ({});

var me2 = {};
var fn2 = function (){
me2.a = 1;
};

speedy.run ({
bind: fn1,
closure: fn2
});

/*
File: bind.js
Node v0.10.20
V8 v3.14.5.9
Speedy v0.1.0
Tests: 2
Timeout: 1000ms (1s 0ms)
Samples: 3
Total time per test: ~3000ms (3s 0ms)
Total time: ~6000ms (6s 0ms)
Higher is better (ops/sec)
bind
8,521,553 ± 0.0%
closure
141,914,040 ± 0.0%
Elapsed time: 6053ms (6s 53ms)
*/
45 changes: 45 additions & 0 deletions examples/call-vs-apply.js
@@ -0,0 +1,45 @@
"use strict";

var speedy = require ("../lib");

var fn = function (a, b, c){
this._a = a;
this._b = b;
this._c = c;
};

//1 closure lookup per test, otherwise apply will create a new array every time
var arr = [1, 2, 3];
var n = 1;

speedy.run ({
call: function (){
fn.call ({}, n, 2, 3);
},
apply: function (){
fn.apply ({}, arr);
}
});

/*
File: call-vs-apply.js
Node v0.10.20
V8 v3.14.5.9
Speedy v0.1.0
Tests: 2
Timeout: 1000ms (1s 0ms)
Samples: 3
Total time per test: ~3000ms (3s 0ms)
Total time: ~6000ms (6s 0ms)
Higher is better (ops/sec)
call
19,160,967 ± 0.4%
apply
13,384,675 ± 0.3%
Elapsed time: 6054ms (6s 54ms)
*/
40 changes: 40 additions & 0 deletions examples/case-insensitive-string-comparison.js
@@ -0,0 +1,40 @@
"use strict";

var speedy = require ("../lib");

speedy.run ({
toLowerCase: function (){
"ABC".toLowerCase () === "abc".toLowerCase ();
},
test: function (){
/^ABC$/i.test ("abc");
},
match: function (){
!!"ABC".match (/^abc$/i);
}
});

/*
File: case-insensitive-string-comparison.js
Node v0.10.20
V8 v3.14.5.9
Speedy v0.1.0
Tests: 3
Timeout: 1000ms (1s 0ms)
Samples: 3
Total time per test: ~3000ms (3s 0ms)
Total time: ~9000ms (9s 0ms)
Higher is better (ops/sec)
toLowerCase
14,483,687 ± 0.0%
test
24,385,809 ± 0.0%
match
15,678,777 ± 0.1%
Elapsed time: 9077ms (9s 77ms)
*/
45 changes: 45 additions & 0 deletions examples/charcodeat.js
@@ -0,0 +1,45 @@
"use strict";

var speedy = require ("../lib");

var s = "abcdefghijklmnopqrstuvwxyz";

speedy.run ({
"char": function (){
var c;
for (var i=0, ii=s.length; i<ii; i++){
c = s[i];
c.charCodeAt (0);
}
},
"string": function (){
var c;
for (var i=0, ii=s.length; i<ii; i++){
c = s[i];
s.charCodeAt (i);
}
}
});

/*
File: charcodeat.js
Node v0.10.20
V8 v3.14.5.9
Speedy v0.1.0
Tests: 2
Timeout: 1000ms (1s 0ms)
Samples: 3
Total time per test: ~3000ms (3s 0ms)
Total time: ~6000ms (6s 0ms)
Higher is better (ops/sec)
char
7,333,696 ± 0.1%
string
13,264,620 ± 0.0%
Elapsed time: 6055ms (6s 55ms)
*/
38 changes: 38 additions & 0 deletions examples/date-vs-hrtime.js
@@ -0,0 +1,38 @@
"use strict";

var speedy = require ("../lib");

var s1 = Date.now ();
var s2 = process.hrtime ();

speedy.run ({
date: function (){
Date.now () - s1;
},
hrtime: function (){
process.hrtime (s2);
}
});

/*
File: date-vs-hrtime.js
Node v0.10.20
V8 v3.14.5.9
Speedy v0.1.0
Tests: 2
Timeout: 1000ms (1s 0ms)
Samples: 3
Total time per test: ~3000ms (3s 0ms)
Total time: ~6000ms (6s 0ms)
Higher is better (ops/sec)
date
23,447,936 ± 0.1%
hrtime
3,262,705 ± 0.0%
Elapsed time: 6055ms (6s 55ms)
*/

0 comments on commit 5602781

Please sign in to comment.