<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.1.0.min.js"></script>
<div id="testElement"></div>
$(window);
$(window);
var p = $(window);
p;
p;
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
test 1 | |
test 2 |
Test name | Executions per second |
---|---|
test 1 | 123364.6 Ops/sec |
test 2 | 250341.1 Ops/sec |
Let's dive into the world of MeasureThat.net and explore what's being tested in this benchmark.
What is being tested?
MeasureThat.net is a platform for creating and running JavaScript microbenchmarks. The provided JSON represents two test cases, each with a unique approach to testing a specific aspect of JavaScript performance. In this case, we're comparing the performance of two approaches:
window
object, which is a fundamental concept in JavaScript.var p = ...
) and usage (p;
).Options compared
The two test cases differ in their approach to accessing and manipulating the window
object:
$(window)
) to access the window
object. This method is commonly used in browser environments, where jQuery or other libraries provide an easy way to manipulate the DOM.p
is assigned the value of the window
object using the var
keyword. The subsequent lines (p;
and p;
) demonstrate simple variable usage.Pros and cons of each approach
Other considerations
When running these benchmarks, consider the following:
$(window)
syntax.p;
) in Test 2 might be more representative of real-world scenarios, where variables are frequently accessed and manipulated.Library usage
In this benchmark, jQuery is used as a library to provide the $
function, which allows for easy access to the window
object. Other libraries might have similar functionality or different syntaxes for accessing the global object.
Special JS features/syntax
None of the provided benchmarks involve special JavaScript features or syntax that require additional explanation.