CODE: /* *************************** PhantomJS Script below will load a webpage pre defined in terminal and return the time it took to load the webpage in full. After the load test it will write the result into a local .csv file to later be used in Jenkins to graph using the Plot Plugin.
By: Andrew Pritykin *************************** */ var page = require('webpage').create(), system = require('system'), t, address; var pageLoadArray = []; var csvContents = ""; fs = require('fs'); if (system.args.length === 1) { console.log('Usage: loadspeed.js <some URL>'); phantom.exit(1); } else { t = Date.now(); address = system.args[1]; page.open(address, function (status) { if (status !== 'success') { console.log('FAIL to load the address'); } else { t = Date.now() - t; console.log('Page title is ' + page.evaluate(function () { return document.title; })); if(t>7000){ console.log('Loading time was too long... ' + t + "msec"); pageLoadArray.push(t); console.log(pageLoadArray.length); console.log(pageLoadArray[0]); //store the time value to the .csv file try { fs.write("Location_TO_CSV_File/time_load.csv time_load.csv", t + ",", 'a'); } catch(e) { console.log(e); } phantom.exit(1); } else{ console.log('Loading time ' + t + ' msec'); pageLoadArray.push(t); console.log(pageLoadArray.length); console.log(pageLoadArray[0]); //store the time value to the .csv file try { fs.write("Location_TO_CSV_File/time_load.csv", t + ",", 'a'); } catch(e) { console.log(e); } } } phantom.exit(); }); } -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.