<head>
<title>Hello World!</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js'></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Curonsys</h1>
</div>
<div data-role="content">
<p>Hello world</p>
</div>
</div>
</body>
function loadScript(url, callback) {
var script = document.createElement('script');
script.src = url;
script.onload = callback;
document.getElementsByTagName('head')[0].appendChild(script);
}
var loaded = function() {
document.write(str);
}
loadScript('http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js', loaded);
loadScript('http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js', loaded);
loadScript('http://code.jquery.com/mobile/1.1.2/jquery.mobile-1.1.2.min.js', loaded);
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
v145 | |
v132 | |
v112 |
Test name | Executions per second |
---|---|
v145 | 2647.2 Ops/sec |
v132 | 1258.1 Ops/sec |
v112 | 980.3 Ops/sec |
Let's break down the provided benchmark definition and test cases.
Benchmark Definition
The benchmark is defined in JSON format, which represents a JavaScript microbenchmark. The Script Preparation Code
section contains a custom function called loadScript
, which loads an external script at a specified URL and executes it when loaded. In this case, the script being loaded is a jQuery Mobile library.
The Html Preparation Code
section defines an HTML page that includes the jQuery Mobile library, as well as some basic structure for the test page.
Individual Test Cases
There are three individual test cases defined:
Each test case has a unique Benchmark Definition
that defines the script to be loaded and executed.
Options Compared
The options being compared in this benchmark are:
These different versions are likely being compared to see which one has the best performance characteristics.
Pros and Cons of Different Approaches
Using a different version of the same library can have pros and cons:
Library - jQuery Mobile
jQuery Mobile is an open-source library that provides a touch-friendly interface for web applications. Its purpose is to simplify the development process by providing pre-built components and functionality for mobile devices.
In this benchmark, the jQuery Mobile library is being used to compare its performance across different versions.
Special JS Feature or Syntax - None
There are no special JavaScript features or syntaxes being tested in this benchmark.
Other Alternatives
Some other alternatives that could be used to test the loading and execution of scripts include:
However, using a custom loadScript
function with a specific library like jQuery Mobile provides a controlled environment for testing script loading and execution characteristics.