Lately I came across with a requirement to calculate the execution time for a certain workflow. This specific workflow was part of the provision stub when requesting a new server in vRA.
Couple of use-cases which I could think of for calculating workflows execution time:
- SLA Measurement – making sure that process and workflows are running under the agreed and acceptable time frame.
- Troubleshooting – let’s assume that there is a process, which you know that it’s supposed the take ~3 minutes to complete.
Suddenly, the same process takes longer time to complete, something like 10 for example. This is where monitoring the workflow execution time becomes very handy.
So, basically – all you need to so is to use the attached code. You’ll need to create a Scriptable Task at the end of the workflow, copy the code, and that’s it.
var startDate = workflow.startDateAsDate.getTime();
var endDate = new Date().getTime();
var diff = (endDate-startDate)/1000;
System.log("Worfklow Execution Time in Seconds: " + diff);
And there you have it:
Well, that was a quick one. I hope you found this post helpful.