+ 9
Find out How long your Function takes to Execute.
Step 1 : Copy the source code till the Timer definition to your code. step 2 : Create a Instance of Timer at the begining of your function. e.g.: ( line:40 )here in Timer timer in function print I really don't know why it is not producing correct Output in sololearn............ But You can Run The code on any other IDE It will surely works. what should I do to run this properly on sololearn? https://code.sololearn.com/cg7ir0InP74v/?ref=app
1 Answer
+ 2
In my tests, the digits that represent high-resolution were not updated. I tested this by the two methods below. I think you want to take the approach of #2 (which increments a counter, but call your function instead). Watch the time and start/stop repeating as soon as you detect a time change, calculating execution time based on how many repeats finished in one timer interval:
1) using lots of iterations and normalizing the result:
https://code.sololearn.com/cRjbtysU5r3o/?ref=app
"Though hi-resolution timer ticks 1 billion times/sec, the scheduler returns every 15xxx microseconds, so the finest measure is 1/64 of a second ... "
2) clamping down on the timer until it changed, then calculating the gap:
https://code.sololearn.com/czP9jC2cdJA8/?ref=app