For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo struct
Range
struct Range
A libkineto activity span recorded via the CompilerRT bridge.
Use Range as a context manager: __enter__ opens a libkineto activity
span when the profiler is enabled and __exit__ closes it. The span is
bound to the with block, so it covers exactly the work inside the block:
from profiling_range import Range
def build_graph() raises:
with Range("graph_compile"):
... # graph build code runs inside the spanTODO(MXTOOLS-190): once the mo.profile.range MLIR op lands, add a
category parameter (mirroring std.runtime.tracing.Trace[level, category]) and a StringSlice name overload for dynamically-built names
(e.g. Range("kernel_" + variant)).
Implemented traitsβ
AnyType,
Copyable,
ImplicitlyCopyable,
ImplicitlyDeletable,
Movable
Methodsβ
__init__β
def __init__(out self, name: StringSlice[StaticConstantOrigin], color: UInt32 = UInt32(0))
Records the span name and color; opening is deferred to __enter__.
Args:
- βname (
StringSlice[StaticConstantOrigin]): The span name. Passed straight through to libkineto in__enter__.StaticStringaccepts both string literals and runtimeStaticStringvalues; this matches the convention used bystd.runtime.tracing.Trace. - βcolor (
UInt32): 24-bit RGB color for trace viewers that honor it. Defaults to 0 (libkineto's default color).
__enter__β
def __enter__(mut self)
Begin a libkineto activity span if the profiler is enabled.
Pairs with __exit__. The enabled state is captured into _began here
so a disable() racing with the scope cannot leave a span begun
without a matching end.
__exit__β
def __exit__(self)
Close the libkineto activity span if __enter__ opened one.
Pairs with the begin call in __enter__. Calling disable() between
entry and exit does not unbalance the libkineto bookkeeping because
_began was captured at entry time.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!