IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

profiler

This module provides GPU profiling functionality.

The profiler module enables performance profiling of GPU code blocks through a simple context manager interface. It includes:

  • ProfileBlock: A context manager for timing code blocks
  • Configurable profiling that can be enabled/disabled at compile time
  • Nanosecond precision timing using perf_counter_ns()
  • Source location tracking for profiled blocks
  • Formatted timing output

Example:

from std.gpu import profiler

with profiler.ProfileBlock("my_kernel"):
# Code to profile
pass

Structs