getComputedStyle Perf

JavaScript performance comparison

Test case created by Michael Sherov

Preparation code

<div id="test" style="box-sizing:content-box;"></div>
<div id="test2" style="box-sizing:content-box;"></div>
<script>
var div = document.getElementById("test"),
 div2 = document.getElementById("test2"),
 gCS = window.getComputedStyle(div);

</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
gCS, access, then set
gCS = window.getComputedStyle(div);
div.style.boxSizing = gCS.boxSizing;
pending…
just set
div.style.boxSizing = "content-box";
pending…
access then set
div.style.boxSizing = gCS.boxSizing;
pending…
style access then set
div.style.boxSizing = div.style.boxSizing;
pending…
gCS, access, then set to other
gCS = window.getComputedStyle(div);
div2.style.boxSizing = gCS.boxSizing;
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:

0 comments

Add a comment