colossalai.utils.timer

class colossalai.utils.timer.Timer

A timer object which helps to log the execution times, and provides different tools to assess the times.

start()

Fisrtly synchronize cuda, reset the clock and then start the timer.

lap()

lap time and return elapsed time

stop(keep_in_history=False)

Stop the timer and record the start-stop time interval.

Parameters

keep_in_history (bool, optional) – Whether does it record into history each start-stop interval, defaults to False

Returns

Start-stop interval

Return type

int

get_history_mean()

Mean of all history start-stop time intervals.

Returns

Mean of time intervals

Return type

int

get_history_sum()

Add up all the start-stop time intervals.

Returns

Sum of time intervals

Return type

int

get_elapsed_time()

Return the last start-stop time interval.

Note

Use it only when timer is not in progress

Returns

The last time interval

Return type

int

reset()

Clear up the timer and its history

class colossalai.utils.timer.MultiTimer(on=True)

An object contains multiple timers

Parameters

on (bool, optional) – Whether the timer is enabled. Default is True

start(name)

Start namely one of the timers

Parameters

name (str) – Timer’s key

stop(name, keep_in_history)

Stop namely one of the timers.

Parameters
  • name (str) – Timer’s key

  • keep_in_history (bool) – Whether does it record into history each start-stop interval

get_timer(name)

Get timer by its name (from multitimer)

Parameters

name – Timer’s key

Returns

Timer with the name you give correctly

Return type

Timer

reset(name=None)

Reset timers.

Parameters

name (optional) – If name is designated, the named timer will be reset and others will not, defaults to None