<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/vqlui.debug3.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>
$("#testRoot span").css("font-family", "'Benton Sans Condensed Regular'");
$("#testRoot2 span").css("font-family", "'Benton Sans Condensed Regular'");
tab.FormattingConverters.cleanUpFontFamilyStyles($("#testRoot"))
tab.FormattingConverters.cleanUpFontFamilyStyles2($("#testRoot2"))
tab.FormattingConverters.cleanUpFontFamilyStyles2($("#testRoot2"))
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
Test 1 | |
Optimized | |
with getComputedStyle dupe |
Test name | Executions per second |
---|---|
Test 1 | 10775.4 Ops/sec |
Optimized | 12424.4 Ops/sec |
with getComputedStyle dupe | 11806.9 Ops/sec |
Let's break down the provided benchmark and explain what is being tested.
Benchmark Overview
The benchmark measures the performance of the cleanUpFontFamilyStyles
function, which is part of the FormattingConverters
library (more on this later). The function takes a DOM element as an argument and optimizes its font family styles.
Options Compared
There are three test cases:
cleanUpFontFamilyStyles
.cleanUpFontFamilyStyles
, which likely applies the necessary optimizations to improve performance.getComputedStyle
on the DOM element before passing it to cleanUpFontFamilyStyles
. The purpose of this test is unclear, as getComputedStyle
is already used in the original implementation.Pros and Cons of Different Approaches
Library: FormattingConverters
The FormattingConverters
library provides utility functions for formatting and optimizing CSS styles in web applications. In this case, cleanUpFontFamilyStyles
is used to optimize font family styles on a DOM element.
Special JS Feature or Syntax (Not Applicable)
There are no special JavaScript features or syntaxes being tested in this benchmark.
Other Alternatives
If the cleanUpFontFamilyStyles
function were to be implemented differently, alternative approaches might include:
Keep in mind that these alternatives are speculative and would depend on the specific requirements and constraints of the project.
In summary, this benchmark measures the performance of the cleanUpFontFamilyStyles
function from the FormattingConverters
library, comparing three different test cases: the original implementation, an optimized version, and a duplicate with the addition of getComputedStyle
. The goal is to identify which implementation is faster and more efficient.