napari.utils.perf.PerfEvent

class napari.utils.perf.PerfEvent(name: str, start_ns: int, end_ns: int, category: Optional[str] = None, process_id: Optional[int] = None, thread_id: Optional[int] = None, phase: str = 'X', **kwargs: dict)[source]

Bases: object

A performance related event: timer, counter, etc.

Parameters
  • name (str) – The name of this event like “draw”.

  • start_ns (int) – Start time in nanoseconds.

  • end_ns (int) – End time in nanoseconds.

  • category (str) – Comma separated categories such has “render,update”.

  • process_id (int) – The process id that produced the event.

  • thread_id (int) – The thread id that produced the event.

  • phase (str) – The Chrome Tracing “phase” such as “X”, “I”, “C”.

  • **kwargs (dict) – Additional keyword arguments for the “args” field of the event.

name

The name of this event like “draw”.

Type

str

span

The time span when the event happened.

Type

Span

category

Comma separated categories such has “render,update”.

Type

str

origin

The process and thread that produced the event.

Type

Origin

args

Arbitrary keyword arguments for this event.

Type

dict

phase
The Chrome Tracing phase (event type):

“X” - Complete Events “I” - Instant Events “C” - Counter Events

Type

str

Notes

The time stamps are from perf_counter_ns() and do not indicate time of day. The origin is arbitrary, but subtracting two counters results in a valid span of wall clock time. If start is the same as the end the event was instant.

Google the phrase “Trace Event Format” for the full Chrome Tracing spec.

Methods

update_end_ns(end_ns)

Update our end_ns with this new end_ns.

Attributes

duration_ms

Duration in milliseconds.

duration_ns

Duration in nanoseconds.

duration_us

Duration in microseconds.

start_ms

Start time in milliseconds.

start_us

Start time in microseconds.

Details

property duration_ms

Duration in milliseconds.

property duration_ns

Duration in nanoseconds.

property duration_us

Duration in microseconds.

property start_ms

Start time in milliseconds.

property start_us

Start time in microseconds.

update_end_ns(end_ns: int) None[source]

Update our end_ns with this new end_ns.

end_ns

The new ending time in nanoseconds.

Type

int