Last active
September 15, 2015 08:21
-
-
Save asimpson/3f1c87c95c5c8a535942 to your computer and use it in GitHub Desktop.
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
webpagetest = require "webpagetest" | |
gulp.task 'test-perf', -> | |
wpt = new webpagetest('www.webpagetest.org', 'APIKEY') | |
parameters = | |
disableHTTPHeaders: true | |
private: true | |
video: true | |
location: 'Dulles:Chrome' | |
login: 'admin' | |
password: 'password' | |
testSpecs = | |
runs: | |
1: | |
firstView: | |
SpeedIndex: 1500 | |
median: | |
firstView: | |
bytesIn: 1000000 | |
visualComplete: 4000 | |
wpt.runTest 'http://someurl.com', parameters, (err, data) -> | |
testID = data.data.testId | |
checkStatus = -> | |
wpt.getTestStatus testID, (err, data) -> | |
console.log "Status for #{testID}: #{data.data.statusText}" | |
unless data.data.completeTime | |
setTimeout checkStatus, 5000 | |
else | |
wpt.getTestResults testID, specs: testSpecs, (err, data) -> | |
console.log "http://www.webpagetest.org/result/#{testID}/" | |
process.exit 1 if err > 0 | |
checkStatus() | |
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
var webpagetest; | |
webpagetest = require("webpagetest"); | |
gulp.task('test-perf', function() { | |
var parameters, testSpecs, wpt; | |
wpt = new webpagetest('www.webpagetest.org', 'APIKEY'); | |
parameters = { | |
disableHTTPHeaders: true, | |
"private": true, | |
video: true, | |
location: 'Dulles:Chrome', | |
login: 'admin', | |
password: 'password' | |
}; | |
testSpecs = { | |
runs: { | |
1: { | |
firstView: { | |
SpeedIndex: 1500 | |
} | |
} | |
}, | |
median: { | |
firstView: { | |
bytesIn: 1000000, | |
visualComplete: 4000 | |
} | |
} | |
}; | |
return wpt.runTest('http://someurl.com', parameters, function(err, data) { | |
var checkStatus, testID; | |
testID = data.data.testId; | |
checkStatus = function() { | |
return wpt.getTestStatus(testID, function(err, data) { | |
console.log("Status for " + testID + ": " + data.data.statusText); | |
if (!data.data.completeTime) { | |
return setTimeout(checkStatus, 5000); | |
} else { | |
return wpt.getTestResults(testID, { | |
specs: testSpecs | |
}, function(err, data) { | |
console.log("http://www.webpagetest.org/result/" + testID + "/"); | |
if (err > 0) { | |
return process.exit(1); | |
} | |
}); | |
} | |
}); | |
}; | |
return checkStatus(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment