field-query
JavaScript performance comparison
Info
Attempt to benchmark object property lookup functions
Preparation code
<script>
Benchmark.prototype.setup = function() {
function query(path) {
return function(target) {
var names = path.split(".")
var count = names.length
var index = 0
var result = target
while (result && index < count) {
result = result[names[index]]
index = index + 1
}
return result
}
}
function query2(path) {
return new Function("$", "return $." + path)
}
var data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map(function(x) {
return { target: { parent: { id: x } } }
})
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
high-order |
|
pending… |
generated |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments