We know from the VCF Automation architecture that the runtime environments (RTE) of Node, PowerShell and Python are executed in their own polyglot runner containers. On the other hand the JavaScript runtime environment is executed in the Orchestrator container. For Node, PowerShell and Python a container is created each time when an action is called, which is not the case with JavaScript. Here we take a look at the additional time required for the creation and removal of containers.
Comparison of RTE Execution Times
To determine the execution times we simply use two comparable actions. The first is an empty Python action and the second is an empty JavaScript action. To make them very similar, a handler function and a property return value have been added to the JavaScript action.
"""
@module de.stschnell
@name testEmptyPython
@version 0.1.0
@runtime python:3.10
@outputType Properties
"""
# import json
def handler(context, inputs):
# jsonOut=json.dumps(inputs, separators=(',', ':'))
# print("Inputs were {0}".format(jsonOut))
outputs = {
"status": "done"
}
return outputs
|
/**
* @module de.stschnell
* @name testEmptyJavaScript
* @version 0.1.0
*
* @outputType Properties
*/
function handler() {
outputs = {
"status": "done"
};
return outputs;
}
return handler();
|
The stopwatch class is used to determine the execution times. Each action is called ten times and the execution time is measured and output in the log. The actions are more or less empty and the measured time will consist almost exclusively of the provision and removal of the RTE.
for (i = 0; i < 10; i++) {
// Python RTE, average approximately 400 ms
var stopWatch1 = System.getModule("de.stschnell").stopWatch();
stopWatch1.start();
System.getModule("de.stschnell ").testEmptyPython();
stopWatch1.stop();
System.log(
"Elapsed time of Python RTE: " +
String(stopWatch1.elapsedTime()) + " ms"
);
// JavaScript RTE, average approximately 2 ms
var stopWatch2 = System.getModule("de.stschnell").stopWatch();
stopWatch2.start();
System.getModule("de.stschnell").testEmptyJavaScript();
stopWatch2.stop();
System.log(
"Elapsed time JavaScript RTE: " +
String(stopWatch2.elapsedTime()) + " ms"
);
}
|
In my case the Python RTE requires an average of approximately 400 ms for this and the JavaScript RTE 2 ms.
Conclusion
The creation and removal of the container is clearly visible here. The absolute time difference looks dramatic, however, this difference is relativized by an increasing runtime. In my opinion this is nothing to worry about.