Skip to content

Commit

Permalink
better benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Llamas committed Oct 6, 2013
1 parent 7b45b07 commit c75f0da
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 17 deletions.
27 changes: 27 additions & 0 deletions benchmark/parse/ini
@@ -0,0 +1,27 @@
[strings]
s1 = v
s2 = v

[numbers]
n1 = 1
n2 = 1
n3 = 123.123
n4 = 123.123

[arrays]
a1[] = 1
a1[] = 1
a1[] = 123.123
a2[] = 1
a2[] = 1
a2[] = 123.123

[objects.o1]
a = 1
b = 1
c = 123.123

[objects.o2]
a = 1
b = 1
c = 123.123
18 changes: 10 additions & 8 deletions benchmark/parse/ini-vs-properties.js
Expand Up @@ -5,27 +5,29 @@ var fs = require ("fs");
var ini = require ("ini");
var properties = require ("../../lib");

var data = fs.readFileSync ("properties", { encoding: "utf8" });
var propertiesData = fs.readFileSync ("properties", { encoding: "utf8" });
var iniData = fs.readFileSync ("ini", { encoding: "utf8" });
var options = {
sections: true,
comments: ";",
separators: "=",
strict: true
strict: true,
json: true
};

speedy.run ({
ini: function (){
ini.parse (data);
ini.parse (iniData);
},
properties: function (){
properties.parse (data, options);
properties.parse (propertiesData, options);
}
});

/*
File: ini-vs-properties.js
Node v0.10.15
Node v0.10.20
V8 v3.14.5.9
Speedy v0.0.8
Expand All @@ -38,9 +40,9 @@ Total time: ~6000ms (6s 0ms)
Higher is better (ops/sec)
ini
31,797 ± 0.2%
23,542 ± 0.2%
properties
43,560 ± 0.0%
31,156 ± 0.2%
Elapsed time: 6061ms (6s 61ms)
Elapsed time: 6162ms (6s 162ms)
*/
10 changes: 5 additions & 5 deletions benchmark/parse/json-vs-properties.js
Expand Up @@ -6,7 +6,7 @@ var fs = require ("fs");

var jsonData = fs.readFileSync ("json", { encoding: "utf8" });
var propertiesData = fs.readFileSync ("properties", { encoding: "utf8" });
var options = { sections: true, json: true };
var options = { sections: true, namespaces: true, json: true };

speedy.run ({
json: function (){
Expand All @@ -23,7 +23,7 @@ speedy.run ({
/*
File: json-vs-properties.js
Node v0.10.15
Node v0.10.20
V8 v3.14.5.9
Speedy v0.0.8
Expand All @@ -36,9 +36,9 @@ Total time: ~6000ms (6s 0ms)
Higher is better (ops/sec)
json
355,037 ± 0.0%
362,515 ± 0.0%
properties
39,191 ± 0.1%
23,823 ± 0.1%
Elapsed time: 6131ms (6s 131ms)
Elapsed time: 6146ms (6s 146ms)
*/
12 changes: 8 additions & 4 deletions benchmark/parse/properties
Expand Up @@ -9,9 +9,13 @@ n3 = 123.123
n4 = 123.123

[arrays]
a1 = ["1", 1, 123.123]
a2 = ["1", 1, 123.123]
a1 = [1, 1, 123.123]
a2 = [1, 1, 123.123]

[objects]
o1 = { "a": "1", "b": 1, "c": 123.123 }
o2 = { "a": "1", "b": 1, "c": 123.123 }
o1.a = 1
o1.b = 1
o1.c = 123.123
o2.a = 1
o2.b = 1
o2.c = 123.123
27 changes: 27 additions & 0 deletions benchmark/parse/yaml
@@ -0,0 +1,27 @@
---
strings:
s1: v
s2: v
numbers:
n1: 1
n2: 1
n3: 123.123
n4: 123.123
arrays:
a1:
- "1"
- 1
- 123.123
a2:
- "1"
- 1
- 123.123
objects:
o1:
a: "1"
b: 1
c: 123.123
o2:
a: "1"
b: 1
c: 123.123
42 changes: 42 additions & 0 deletions benchmark/parse/yaml-vs-properties.js
@@ -0,0 +1,42 @@
"use strict";

var speedy = require ("speedy");
var yaml = require ("js-yaml");
var properties = require ("../../lib");
var fs = require ("fs");

var propertiesData = fs.readFileSync ("properties", { encoding: "utf8" });
var yamlData = fs.readFileSync ("yaml", { encoding: "utf8" });
var options = { sections: true, namespaces: true, json: true };

speedy.run ({
yaml: function (){
yaml.safeLoad (yamlData);
},
properties: function (){
properties.parse (propertiesData, options);
}
});

/*
File: yaml-vs-properties.js
Node v0.10.20
V8 v3.14.5.9
Speedy v0.0.8
Benchmarks: 2
Timeout: 1000ms (1s 0ms)
Samples: 3
Total time per benchmark: ~3000ms (3s 0ms)
Total time: ~6000ms (6s 0ms)
Higher is better (ops/sec)
yaml
14,565 ± 1.3%
properties
23,653 ± 0.2%
Elapsed time: 6147ms (6s 147ms)
*/

0 comments on commit c75f0da

Please sign in to comment.