In this tutorial, we will show you how to use Neocortix Cloud Services Scalable Compute to run a distributed Performance Test batch job, using a Puppeteer and Lighthouse client.
First, please follow the steps in the tutorial
Setting Up For Batch Jobs.
After completion of the initial setup, you will have a directory with examples,
~/ncsexamples
.
In the subdirectory
~/ncsexamples/batchMode
you will find the
runBatchPuppeteerLighthouse.py command.
This script will create a set of instances running on mobile devices, one instance for each load generator.
In the default example provided, we ask for 5 successful instances:
startFrame = 1,
endFrame = 5,
nWorkers = 10,
By setting
nWorkers = 10
, we slightly over-allocate instances to allow for some fraction to fail.
It will command the instances to install
Node.js, Chromium, Puppeteer, and Lighthouse, and then run Puppeteer to capture a screenshot of the Google.com home page, and then run Lighthouse to
analyze the Google.com home page.
def frameCmd( self, frameNum ):
cmd = 'date && export NODE_PATH=/usr/local/lib/node_modules && export PATH=$PATH:/usr/local/bin && node %s && lighthouse https://www.google.com --no-enable-error-reporting --chrome-flags="--headless --no-sandbox" --emulated-form-factor=none --throttling-method=provided && mv google.png google_%03d.png && mv *google*.html google_%03d.html && tar -zcvf Puppeteer_results_%03d.tar.gz google*' % (
self.PuppeteerFilePath, frameNum, frameNum, frameNum
)
return cmd
The output of each instance will be a Puppeteer screenshot image file
google_<n>.png
and a
Lighthouse performance report
google_<n>.html
. It will also produce a
Map.png
file, showing the locations
of all the instances.