Last active
August 29, 2015 14:19
-
-
Save axemclion/622afbdc1bba3193f5b2 to your computer and use it in GitHub Desktop.
SVG Scroll tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Collects runtime rendering metrics for animated spinners from http://codepen.io/axemclion/debug/myZQWE? | |
| Instructions to run tests: | |
| 1. Download Chromedriver from https://sites.google.com/a/chromium.org/chromedriver/ and start it | |
| 2. Do npm install browser-perf | |
| 3. Run this file | |
| */ | |
| var browserPerf = require('browser-perf'); | |
| var fs = require('fs'); | |
| var MAX_SPINNERS = 8; | |
| var BASE_URL = 'http://codepen.io/axemclion/debug/myZQWE?'; | |
| var BROWSERS = { | |
| 'desktopChrome': 'chrome' | |
| }; | |
| var TEST_BROWSER = 'desktopChrome'; | |
| var SELENIUM = 'http://localhost:9515'; | |
| function saveResults(device, num, res) { | |
| var data = {}; | |
| var fileName = device + '.json'; | |
| if (!fs.existsSync(fileName)) { | |
| fs.writeFileSync(fileName, '{}'); | |
| } | |
| try { | |
| data = JSON.parse(fs.readFileSync(fileName)); | |
| } catch (e) {} | |
| if (typeof data[num] === 'undefined') { | |
| data[num] = {}; | |
| } | |
| for (var key in res) { | |
| if (typeof data[num][key] === 'undefined') { | |
| data[num][key] = []; | |
| } | |
| data[num][key].push(res[key]); | |
| } | |
| fs.writeFileSync(fileName, JSON.stringify(data)); | |
| } | |
| (function runTest(spinnerCount) { | |
| if (spinnerCount <= MAX_SPINNERS) { | |
| browserPerf(BASE_URL + spinnerCount, function(err, res) { | |
| if (!err) { | |
| saveResults(TEST_BROWSER, spinnerCount, res[0]); | |
| } | |
| runTest(spinnerCount + 1); | |
| }, { | |
| actions: [browserPerf.actions.scroll({ | |
| scrollElement: "document.getElementsByTagName('ion-content')[0]" | |
| })], | |
| browserName: [BROWSERS[TEST_BROWSER]], | |
| selenium: SELENIUM | |
| }); | |
| } else { | |
| console.log('All tests done'); | |
| } | |
| }(1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
