armi.utils.codeTiming module

Utilities related to profiling code.

armi.utils.codeTiming.timed(*args)[source]

Decorate functions to measure how long they take.

Examples

@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
armi.utils.codeTiming.getMasterTimer()[source]

Duplicate function to the MasterTimer.getMasterTimer method.

Provided for convenience and developer preference of which to use

class armi.utils.codeTiming.MasterTimer[source]

Bases: object

static getMasterTimer()[source]
static getTimer(event_name)[source]

Return a timer with no special action take.

with timer: ... friendly!

static startTimer(event_name)[source]

Return a timer with a start call, or a newly made started timer.

with timer: ... unfriendly!

static endTimer(event_name)[source]

Return a timer with a stop call, or a newly made unstarted timer.

with timer: ... unfriendly!

static time()[source]

System time offset by when this master timer was initialized.

static startAll()[source]

Starts all timers, won’t work after a stopAll command.

static stopAll()[source]

Kills the timer run, can’t easily be restarted.

static getActiveTimers()[source]
static report(inclusion_cutoff=0.1, total_time=False)[source]

Write a string report of the timers.

Parameters:
  • inclusion_cutoff (float, optional) – Will not show results that have less than this fraction of the total time.

  • total_time (bool, optional) – Use either the ratio of total time or time since last report for consideration against the cutoff

See also

armi.utils.codeTiming._Timer.__str__

prints out the results for each individual line item

static timeline(base_file_name, inclusion_cutoff=0.1, total_time=False)[source]

Produces a timeline graphic of the timers.

Parameters:
  • base_file_name (str) – whatever the leading file path should be this method generates the same file extension for every image to add to the base

  • inclusion_cutoff (float, optional) – Will not show results that have less than this fraction of the total time.

  • total_time (bool, optional) – Use either the ratio of total time or time since last report for consideration against the cutoff