text content
JavaScript performance comparison
Preparation code
<div id="text">content to be retrieved</div>
<script>
var elem = document.getElementById("text");
var elem2 = document.createElement('div');
var preTextNode = document.createTextNode('Hello there');
</script>
<script>
Benchmark.prototype.setup = function() {
elem2 = document.createElement('div');
elem.innerHTML = 'content to be retrieved';
};
Benchmark.prototype.teardown = function() {
elem2 = document.createElement('div');
elem.innerHTML = 'content to be retrieved';
};
</script>
Preparation code output
content to be retrieved
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
read innerHTML |
|
pending… |
read textContent |
|
pending… |
read data |
|
pending… |
write innerHTML |
|
pending… |
write textContent |
|
pending… |
write data |
|
pending… |
write data w/ check |
|
pending… |
write data w/ check 2 |
|
pending… |
write data w/o check 2 |
|
pending… |
write data w/o check 2b |
|
pending… |
write data w/o check 3b |
|
pending… |
write data w/ check 2+ |
|
pending… |
replace w/ string |
|
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 galambalazs
- Revision 2: published by galambalazs
- Revision 3: published by galambalazs
- Revision 9: published by aeosynth
- Revision 10: published by Mayhem
- Revision 11: published
0 comments