UNPKG

8o

Version:

Oxide (8O) is a javascript library to get connection information and allows the browser to load certain content only if a minimum speed requirements are met.

902 lines (192 loc) 9.67 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: OxideBenchmarker</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Class: OxideBenchmarker</h1> <section> <header> <h2>OxideBenchmarker</h2> </header> <article> <div class="container-overview"> <h4 class="name" id="OxideBenchmarker"><span class="type-signature"></span>new OxideBenchmarker<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Downloads resources and uses them to run a crude speed test. As a side effect the resources will be cached by your browser after the test, so the benchmarker can double as a preloader. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="benchmarker.js.html">benchmarker.js</a>, <a href="benchmarker.js.html#line7">line 7</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Members</h3> <h4 class="name" id="benchmarkQueue"><span class="type-signature"></span>benchmarkQueue<span class="type-signature"> :Array</span></h4> <div class="description"> Holds the queue of resources to load. Resources are not loaded concurrently to prevent different benchmarks from slowing eachother down. </div> <h5>Type:</h5> <ul> <li> <span class="param-type">Array</span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="benchmarker.js.html">benchmarker.js</a>, <a href="benchmarker.js.html#line28">line 28</a> </li></ul></dd> </dl> <h4 class="name" id="benchmarkResults"><span class="type-signature"></span>benchmarkResults<span class="type-signature"> :Array</span></h4> <div class="description"> Holds the results of the speeds tests grouped by url </div> <h5>Type:</h5> <ul> <li> <span class="param-type">Array</span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="benchmarker.js.html">benchmarker.js</a>, <a href="benchmarker.js.html#line18">line 18</a> </li></ul></dd> </dl> <h4 class="name" id="benchmarkState"><span class="type-signature"></span>benchmarkState<span class="type-signature"> :string</span></h4> <div class="description"> Read and updated by the benchmark queue handler to prevent concurrent resource loads. Can be one of these values: - BENCHMARK_STATE_IDLE: not doing any requests and the benchmark queue is empty, any call to benchmark() now would not interfere with other calls. - BENCHMARK_STATE_QUEUE: not doing any request right now but there are still items in the queue, a call to benchmark() now would slow down handling of the queue - BENCHMARK_STATE_BUSY: busy doing one or more requests, a call to benchmark() now would reduce reliability of the results </div> <h5>Type:</h5> <ul> <li> <span class="param-type">string</span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="benchmarker.js.html">benchmarker.js</a>, <a href="benchmarker.js.html#line41">line 41</a> </li></ul></dd> </dl> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="benchmark"><span class="type-signature"></span>benchmark<span class="signature">(resource)</span><span class="type-signature"></span></h4> <div class="description"> Benchmarks an item immediately. Used by the benchmark queue handler. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>resource</code></td> <td class="type"> </td> <td class="description last">the url of the resource to load.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="benchmarker.js.html">benchmarker.js</a>, <a href="benchmarker.js.html#line82">line 82</a> </li></ul></dd> </dl> <h4 class="name" id="getSpeed"><span class="type-signature"></span>getSpeed<span class="signature">()</span><span class="type-signature"> &rarr; {number}</span></h4> <div class="description"> Calculates the average speed over all completed benchmarks in the result table. Returned value is in kilobytes (SI definition) per second. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="benchmarker.js.html">benchmarker.js</a>, <a href="benchmarker.js.html#line119">line 119</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">number</span> </dd> </dl> <h4 class="name" id="load"><span class="type-signature"></span>load<span class="signature">(resource)</span><span class="type-signature"></span></h4> <div class="description"> Adds a resource to the benchmark queue. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>resource</code></td> <td class="type"> </td> <td class="description last">the url of the resource to load.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="benchmarker.js.html">benchmarker.js</a>, <a href="benchmarker.js.html#line74">line 74</a> </li></ul></dd> </dl> <h4 class="name" id="work"><span class="type-signature"></span>work<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Processes the current benchmark queue. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="benchmarker.js.html">benchmarker.js</a>, <a href="benchmarker.js.html#line55">line 55</a> </li></ul></dd> </dl> <h4 class="name" id="worker"><span class="type-signature"></span>worker<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Benchmark queue handler. If for any reason you want to stop it, call clearTimeout() on this. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="benchmarker.js.html">benchmarker.js</a>, <a href="benchmarker.js.html#line47">line 47</a> </li></ul></dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="OxideBenchmarker.html">OxideBenchmarker</a></li><li><a href="OxideStorage.html">OxideStorage</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Sat Apr 01 2017 07:18:01 GMT+0000 (UTC) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>