Created
October 4, 2014 23:53
-
-
Save axemclion/d41b884cd4fce723647d to your computer and use it in GitHub Desktop.
Capture Chrome timeline for CSS triggers.com
This file contains 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
// Remeber to do npm install wd and run a web server where the pages are hosted. | |
var wd = require('wd'); | |
var path = require('path'); | |
var browser = wd.promiseRemote(); | |
var caps = { | |
browserName: 'chrome', | |
loggingPrefs: { | |
performance: 'ALL' | |
} | |
}; | |
browser.init(caps).then(function() { | |
return browser.get('http://localhost:8080/align-content-initial.html'); // CHANGE THIS | |
}).then(function() { | |
return browser.sleep(1000); | |
}).then(function() { | |
return browser.log('performance'); | |
}).then(function() { | |
return browser.eval('go();'); | |
}).then(function() { | |
return browser.sleep(1200); | |
}).then(function() { | |
return browser.waitForConditionInBrowser('window.isDone===true', 1000, 5000); | |
}).then(function() { | |
return browser.log('performance'); | |
}).then(function(logs) { | |
return logs.map(function(log) { | |
return JSON.parse(log.message).message.params.record; | |
}); | |
}).then(parseLogs).fin(function() { | |
server.close(); | |
browser.close(); | |
}).done(); | |
var props = ['Layout', 'Paint', 'CompositeLayers']; | |
function parseLogs(logs) { | |
logs.forEach(function(log) { | |
console.log(log.type); | |
if (Array.isArray(log.children)) { | |
parseLogs(log.children); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment