Closed michaelbynum closed 4 years ago
Merging #96 into master will increase coverage by
0.79%
. The diff coverage is93.75%
.
@@ Coverage Diff @@
## master #96 +/- ##
==========================================
+ Coverage 63.13% 63.93% +0.79%
==========================================
Files 87 87
Lines 8788 8916 +128
==========================================
+ Hits 5548 5700 +152
+ Misses 3240 3216 -24
Impacted Files | Coverage Δ | |
---|---|---|
pyutilib/misc/timing.py | 76.76% <93.75%> (+76.76%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update ad6043c...913df89. Read the comment docs.
@jsiirola Great suggestions. I never realized the TicTocTimer
tracked cumulative time and number of calls. I also did not know about time.perf_counter
or time.clock
, so thanks. Let me know what you think of the new changes.
@jsiirola I think this is ready now. Thanks for all the great suggestions. I am very happy with this timer now.
@michaelbynum: some questions/comments as I go through this:
'%.3f'
, and I think that is a good precedent: timings under a millisecond are meaningless, and I (at least) get lost tracking exponents
'%8d %8.3f %8.3f %5.1f'
: this makes things more compact, yet ensures in the odd chance that timings run over 10000 seconds that there is still a space between numbers..format()
? It is verbose, harder to parse, and generally 2x slower that classic formatting (using '%
'). We can move to f-strings when we finally drop 2.x and 3.5 (f-strings are faster than '%
' and more concise, but not available until 3.6)get_total_time
and get relative_precent_time
could be calculated locally within the Helper. This actually motivated the previous comment, as I was working through the complexity of the printer (the logic is basically duplicated in both the HierarchicalTimer and in the _HierarchicalHelper_cumul
attribute, as it will return the wrong answer if the timer is currently running. Always access it with toc(msg='')
I have some ideas around addressing the above. Would you like me to draft something as a PR to your branch?
@jsiirola
HierarchicalTimer
is not terribly important. get_relative_percent_time
in the helper object is that the helper object does not currently have a pointer to its parent. Again, I am fine with these changes if you want to make a PR. _cumul
. @jsiirola Looks good. Thanks for these changes.
I agree. Thank you both for this - this looks great - and will definitely get used in a few of our projects.
Summary/Motivation:
This Pr adds a class for hierarchical timing.
Legal Acknowledgement
By contributing to this software project, I agree to the following terms and conditions for my contribution: