Data vs. Accessor Properties
JavaScript performance comparison
Info
The purpose of this benchmark is to determine if there is a performance difference between data properties and access are properties.
Preparation code
<script>
Benchmark.prototype.setup = function() {
var data = { property: undefined };
var accessor = {
get property() {
// noop
},
set property(value) {
// noop
}
};
var method = { property: function(){} };
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Write to data property |
|
pending… |
Write to accessor property |
|
pending… |
Read from data property |
|
pending… |
Read from accessor property |
|
pending… |
Calling a method |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by Nicholas C. Zakas
0 comments