Is there a way to log the time a script needs for execution?
Hi Andre,
that "extra" time you encounter is most likely the time the final transaction needs to commit. That happens *after* the script has basically finished. That time as you mentioned highly depends on what you script does, if it just reads, its probably 0ms, but if you add or change huge amount of data, it may take some time. 15 min on the other hand is extreme so I wonder what your script is doing.
Its more or less impossible for a script itself to reach beyond its execution so outside of it sandbox. So you cant measure it inside the script itself.
There is some hidden feature that if you run the tool in dev mode, the *full* amount of the script execution (ramp up, script + commit) is show in the left lower corner of the tool:
I think we can (should) show that time always even in normal mode, maybe in next tool version.
Happy Scripting
Jan
Joel,
you might just try using the standard JS ways of measuring time:
https://stackoverflow.com/questions/41632942/how-to-measure-time-elapsed-on-javascript
Does that work?
Regards,
Nils
Yes that should work ... or just very simple
const start = Date.now();console.log('starting timer...');//instead of the for insert the call to your scriptfor(var i=1;i<10000;i++) {console.log(i)}console.log('Time expired {0}',Date.now()-start)
Some more thoughts: there is an official simple API to track time n the console, see https://developer.mozilla.org/en-US/docs/Web/API/console/time.
However, our console does not have that API, so one way is to search a polyfill for that API (there is an article on polyfill here in the forum) or write an own API.
I like the Google Guava Stopwatch API so one way would be to directly use it (with bind) or use an own similar API. I once tried to write one, I have attached the result, not the bets code but simple.
Hi,
We measure the execution time of our scripts in a manner similar to the one suggested by Nils and Eckhardt. The last code line is a console output stating that the script just finished.
One thing we noticed however is that for some scripts,
the console indeed shows that the script was finished,
but it still takes a lot of time to update the model and return the control to the user.
Something like: 3 minutes for the script, 15 minutes for the model update
(specially for the cases where thousands of elements are updated).
Is there any way to measure this "model update time"?
Thanks!
All the best, Andre