You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i was to measure execution time with perfcounter and convert that to a Duration to take advantage of the attributes in formatting a logging message.
It seems like to do this one has to do roughly:
start = perfcounter() # run some stuff that takes time elapsed = perfcounter() - start elapsed_msec, elapsed_sec = math.modf(elapsed) elapsed_msec = elapsed_msec * 100 elapsed_d= Duration(seconds=elapsed_sec, milliseconds=elapsed_msec) log.info(f'Elapsed time: {elapsed_d.hours}:' f'{elapsed_d.minutes}:' f'{elapsed_d.remaining_seconds}' )
This seems a little convoluted, but conversely using Datetime.now() doesn't capture any time elapsed for relatively fast intervals, so I'm not sure of a better way to achieve this.
Edit- For context this is for wrapping around some data processing functionality, so a large dataset may conceivably take a few hours but a test case or a small dataset may take virtually no time, hence the interest in easy access to the Duration's hour minute and second attributes while also capturing small spans of time as well.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
i was to measure execution time with perfcounter and convert that to a Duration to take advantage of the attributes in formatting a logging message.
It seems like to do this one has to do roughly:
This seems a little convoluted, but conversely using
Datetime.now()doesn't capture any time elapsed for relatively fast intervals, so I'm not sure of a better way to achieve this.Edit-
For context this is for wrapping around some data processing functionality, so a large dataset may conceivably take a few hours but a test case or a small dataset may take virtually no time, hence the interest in easy access to the Duration's hour minute and second attributes while also capturing small spans of time as well.
Beta Was this translation helpful? Give feedback.
All reactions