Created
June 14, 2015 10:46
-
-
Save floatdrop/c4cbe0a90a084373653c to your computer and use it in GitHub Desktop.
Matcha benchmark for dot-prop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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