Load Test Output
In this tutorial, we will show you how to use Neocortix Cloud Services Scalable Compute to run a distributed batch job using JavaScript and node.js.
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,
In the subdirectory
you will find the runBatchJavascript.py command. This script will create a set of instances running on mobile devices, one instance for each frame to be computed (5 in the default example provided).
startFrame = 1, endFrame = 5,
It will command the instances to receive the JavaScript file
, then run it:
workerScriptPath = 'helloFrame.js' def frameCmd( self, frameNum ): jsFileName = os.path.basename( self.workerScriptPath ) cmd = 'node %s %d > %s' % \ (jsFileName, frameNum, self.frameOutFileName(frameNum)) return cmd
The output is a text file
"Hello World! From frameNum = n"
These output files will be sent back to the master host, and the master will then terminate the instances.

Example Command

Simply run
python3 ./runBatchJavascript.py
When the program is done, the output files
will be put in a directory
Each file will contain the text output
Hello World! From frameNum = n

Substituting Your Own JavaScript file

With this simple framework, you can easily substitute your own JavaScript file to process the frames of the Batch job. Just edit the
file to change the
to replace
with the name of your JavaScript file
, which runs on an instance and processes a single frame. You may need to install different dependencies in the
Pro Tip: When you are experimenting with getting your code running on a Neocortix Scalable Compute instance, it may be easiest to spin up a single instance and get it installed and running there, before running it at scale as a part of a Batch job.