armi.utils.codeTiming module
Utilities related to profiling code.
- armi.utils.codeTiming.timed(*args)[source]
Decorate functions to measure how long they take.
Examples
Here are some examples of using this method:
@timed # your timer will be called the module+method name def mymethod(stuff): do stuff @timed('call my timer this instead') def mymethod2(stuff) do even more stuff
- class armi.utils.codeTiming.MasterTimer[source]
Bases:
object
A code timing interface, this class is designed to be a singleton.
- static getMasterTimer()[source]
Primary method that users need get access to the MasterTimer singleton.
- static getTimer(eventName)[source]
Return a timer with no special action take.
with timer: ...
friendly!
- static startTimer(eventName)[source]
Return a timer with a start call, or a newly made started timer.
with timer: ...
unfriendly!
- static endTimer(eventName)[source]
Return a timer with a stop call, or a newly made unstarted timer.
with timer: ...
unfriendly!
- static report(inclusionCutoff=0.1, totalTime=False)[source]
Write a string report of the timers.
This report prints a table that looks something like this:
TIMER REPORTS CUMULATIVE (s) AVERAGE (s) NUM ITERS thing1 0.01 0.01 1 thing2 0.01 0.01 1 TOTAL TIME 0.02 0.02 1
- Parameters:
See also
armi.utils.codeTiming._Timer.__str__
prints out the results for each individual line item
- Returns:
str
- Return type:
Plain-text table report on the timers.
- static timeline(baseFileName, inclusionCutoff=0.1, totalTime=False)[source]
Produces a timeline graphic of the timers.
- Parameters:
baseFileName (str) – Whatever the leading file path should be. This method generates the same file extension for every image to add to the base.
inclusionCutoff (float, optional) – Will not show results that have less than this fraction of the total time.
totalTime (bool, optional) – Use the ratio of total time or time since last report to compare against the cutoff.
- Returns:
str
- Return type:
Path to the saved plot file.