Skip to content

Instantly share code, notes, and snippets.

@floatdrop
Created June 14, 2015 10:46
Show Gist options
  • Save floatdrop/c4cbe0a90a084373653c to your computer and use it in GitHub Desktop.
Save floatdrop/c4cbe0a90a084373653c to your computer and use it in GitHub Desktop.
Matcha benchmark for dot-prop
// npm i matcha -g
// matcha bench.js
var dotProp = require('./');
var testObject = {
a: {
b: {
c: {
d: {
e: {
f: {count: 0}
},
count: 0
},
count: 0
},
count: 0
},
count: 0
}
};
bench('get a', function() {
var obj = dotProp.get(testObject, 'a');
obj.count++;
});
bench('get a.b', function() {
var obj = dotProp.get(testObject, 'a.b');
obj.count++;
});
bench('get a.b.c', function() {
var obj = dotProp.get(testObject, 'a.b.c');
obj.count++;
});
bench('get a.b.c.d', function() {
var obj = dotProp.get(testObject, 'a.b.c.d');
obj.count++;
});
bench('get a.b.c.d.e', function() {
var obj = dotProp.get(testObject, 'a.b.c.d.e');
obj.count++;
});
bench('get a.b.c.d.e.f', function() {
var obj = dotProp.get(testObject, 'a.b.c.d.e.f');
obj.count++;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment