<script type="text/javascript" src="https://publicstatic.tableausoftware.com/vizql/v_100001608191615/javascripts/mscorlib.js"></script>
<script type="text/javascript" src="https://dl.dropboxusercontent.com/u/2186277/vqlcore.debug.js"></script>
<div id="testRoot">
<span>1</span>
<span>1</span>
<span>1</span>
<span>1</span>
<span>1</span>
<span>1</span>
<span>1</span>
</div>
<div id="testRoot2">
<span>1</span>
<span>1</span>
<span>1</span>
<span>1</span>
<span>1</span>
<span>1</span>
<span>1</span>
</div>
var box = { l: 10, t: 20, w: 30, h: 40 };
tab.DomUtil.setMarginBoxJQ($("#testRoot"), box);
tab.DomUtil.setMarginBoxJQ2($("#testRoot2"), box);
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
Test 1 | |
Optimized |
Test name | Executions per second |
---|---|
Test 1 | 5672.4 Ops/sec |
Optimized | 13953.8 Ops/sec |
Let's break down the provided JSON data and explain what is tested on MeasureThat.net.
Benchmark Definition
The benchmark definition represents a microbenchmark test that measures the performance of setting margins using two different JavaScript functions: tab.DomUtil.setMarginBoxJQ
and tab.DomUtil.setMarginBoxJQ2
.
Script Preparation Code
The script preparation code provides the JavaScript context for the benchmark. It includes links to external libraries (mscorlib.js
and vqlcore.debug.js
) that are used in the test.
Html Preparation Code
The HTML preparation code defines the DOM structure used in the benchmark. Two identical containers with six spans each are created, which will be used as targets for setting margins.
Individual Test Cases
There are two individual test cases:
Test 1
: This test case uses the original tab.DomUtil.setMarginBoxJQ
function to set margins on the first container (#testRoot
).Optimized
: This test case uses an optimized version of the same function, tab.DomUtil.setMarginBoxJQ2
, which is likely a refactored or improved implementation.Library and Purpose
Both libraries are part of a larger framework used for data visualization and visualization in Tableau Software (mscorlib.js). The DomUtil
namespace appears to provide utility functions for working with the DOM, including setting margins.
Special JavaScript Feature or Syntax
There is no explicit mention of special JavaScript features or syntax used in this benchmark. However, it's worth noting that the use of $(selector)
suggests that jQuery is being used as a library.
Options Compared
The two test cases compare the performance of using the original tab.DomUtil.setMarginBoxJQ
function versus the optimized version (tab.DomUtil.setMarginBoxJQ2
). The comparison aims to determine which approach is faster and more efficient.
Pros and Cons of Different Approaches
Without seeing the actual implementation code, it's difficult to provide a detailed analysis. However, here are some general pros and cons:
tab.DomUtil.setMarginBoxJQ
function:tab.DomUtil.setMarginBoxJQ2
function:Other Alternatives
There might be other approaches to setting margins that are not being compared in this benchmark. Some alternatives could include:
element.style.marginTop
)Keep in mind that these alternative approaches might have their own pros and cons, which would need to be evaluated on a case-by-case basis.