warp.ScopedTimer#

class warp.ScopedTimer(
name,
active=True,
print=True,
detailed=False,
dict=None,
use_nvtx=False,
color='rapids',
synchronize=False,
cuda_filter=0,
report_func=None,
skip_tape=False,
)[source]#

Context manager for timing code blocks.

This context manager measures the execution time of the enclosed code block and can optionally print the elapsed time, collect detailed profiling data, or record NVTX ranges.

Parameters:
__init__(
name,
active=True,
print=True,
detailed=False,
dict=None,
use_nvtx=False,
color='rapids',
synchronize=False,
cuda_filter=0,
report_func=None,
skip_tape=False,
)[source]#

Context manager object for a timer

Parameters:
  • name (str) – Name of timer

  • active (bool) – Enables this timer

  • print (bool) – At context manager exit, print elapsed time to sys.stdout

  • detailed (bool) – Collects additional profiling data using cProfile and calls print_stats() at context exit

  • dict (dict[str, list[float]] | None) – A dictionary of lists to which the elapsed time will be appended using name as a key

  • use_nvtx (bool) – If true, timing functionality is replaced by an NVTX range

  • color (int | str) – ARGB value (e.g. 0x00FFFF) or color name (e.g. ‘cyan’) associated with the NVTX range

  • synchronize (bool) – Synchronize the CPU thread with any outstanding CUDA work to return accurate GPU timings

  • cuda_filter (int) – Filter flags for CUDA activity timing, e.g. warp.TIMING_KERNEL or warp.TIMING_ALL

  • report_func (Callable[[list[TimingResult], str], None] | None) – A callback function to print the activity report. If None, warp.timing_print() will be used.

  • skip_tape (bool) – If true, the timer will not be recorded in the tape

extra_msg#

Can be set to a string that will be added to the printout at context exit.

Type:

str

elapsed#

The duration of the with block used with this object

Type:

float

timing_results#

The list of activity timing results, if collection was requested using cuda_filter

Type:

list[TimingResult]

Methods

__init__(name[, active, print, detailed, ...])

Context manager object for a timer

Attributes

enabled = True#