diff options
author | Saivan <savian@me.com> | 2018-02-27 17:23:59 +1100 |
---|---|---|
committer | Saivan <savian@me.com> | 2018-02-27 17:23:59 +1100 |
commit | 1cb509f863b17af90827012e6f6ae81cb694f654 (patch) | |
tree | 97155f552708385cb85b209ba0e6c2ccc523bbdf /bench | |
parent | 4b078f8732a494b7f184556f276b011317a766b5 (diff) | |
download | svg.js-1cb509f863b17af90827012e6f6ae81cb694f654.tar.gz svg.js-1cb509f863b17af90827012e6f6ae81cb694f654.zip |
Made developing a little more enjoyable
This commit adds playgrounds and a build:dev mode. Now you
can call npm run build:dev to make the linter warn you about
errors without breaking. Also, we now have playgrounds, where
you can use a built version of svg.js to run your own tests.
Diffstat (limited to 'bench')
-rw-r--r-- | bench/svg.bench.js | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/bench/svg.bench.js b/bench/svg.bench.js index 5b9541e..50ef547 100644 --- a/bench/svg.bench.js +++ b/bench/svg.bench.js @@ -1,56 +1,55 @@ -;( function() { +/* global Snap */ +;(function () { SVG.bench = { // Initalize test store - _chain: [] - , _before: function() {} - , _after: function() {} - , draw: SVG().addTo('#draw') - , snap: Snap(100, 100) - , raw: document.getElementById('native') + _chain: [], + _before: function () {}, + _after: function () {}, + draw: SVG().addTo('#draw'), + snap: Snap(100, 100), + raw: document.getElementById('native'), // Add descriptor - , describe: function(name, closure) { + describe: function (name, closure) { this._chain.push({ - name: name - , run: closure + name: name, + run: closure }) return this - } + }, // Add test - , test: function(name, run) { + test: function (name, run) { // run test - var start = ( new Date ).getTime() + var start = (new Date()).getTime() run() - this.write( name, ( new Date ).getTime() - start ) + this.write(name, (new Date()).getTime() - start) // clear everything this.clear() - } + }, // Skip test - , skip: function(name, run) { - this.write( name, false ) - } + skip: function (name, run) { + this.write(name, false) + }, // Run tests - , run: function() { + run: function () { this.pad() - + for (var h, i = 0, il = this._chain.length; i < il; i++) { - var h = document.createElement('h1') + h = document.createElement('h1') h.innerHTML = this._chain[i].name - this.pad().appendChild(h) - this._chain[i].run(this) } - } - + }, + // Write result - , write: function(name, ms) { + write: function (name, ms) { var test = document.createElement('div') if (typeof ms === 'number') { @@ -60,14 +59,14 @@ test.className = 'test skipped' test.innerHTML = name + ' (skipped)' } - + this.pad().appendChild(test) return this - } + }, // Reference writable element - , pad: function() { + pad: function () { var pad = document.getElementById('pad') if (!pad) { @@ -76,15 +75,15 @@ } return pad - } + }, // Clear canvasses - , clear: function() { - while(this.raw.hasChildNodes()) + clear: function () { + while (this.raw.hasChildNodes()) { this.raw.removeChild(this.raw.lastChild) + } this.draw.clear() this.snap.clear() } } - -})();
\ No newline at end of file +})() |