line_profilerintegration with a zero-cost no-op decorator by default; activated via theENABLE_LINE_PROFILER=1environment variable for line-level timing of hot-path functions.
Component specs: async_utils · commands · config · core · dataset_manager · endpoint_client · evaluation · load_generator · metrics · openai · plugins · profiling · sglang · testing · utils
profiling/ integrates line_profiler into the benchmark run and provides a pytest plugin for
profiling during test execution. It is a developer tool with no effect on production runs unless
explicitly enabled.
- Wrap functions with
line_profiler.LineProfilerfor line-level timing - Emit profiling output at the end of a benchmark or test run
- Provide a pytest plugin that activates profiling when
ENABLE_LINE_PROFILER=1is set
| File | Purpose |
|---|---|
line_profiler.py |
profile() decorator and dump_stats() utility |
pytest_profiling_plugin.py |
pytest plugin; hooks into test session lifecycle |
from inference_endpoint.profiling import profile
@profile
def hot_function(...):
...When profiling is inactive (default), @profile is a no-op. When active, it wraps the function
with LineProfiler and accumulates timing across all calls.
In tests:
ENABLE_LINE_PROFILER=1 pytest tests/unit/...No-op decorator by default
Importing @profile from profiling/ is safe in production code. When profiling is not
enabled, the decorator returns the original function unchanged. This means profiling annotations
can remain in hot-path code without any runtime cost.
ENABLE_LINE_PROFILER env var for selective activation
Setting ENABLE_LINE_PROFILER=1 activates profiling for the process in question. This avoids
permanently modifying the code; @profile annotations can remain in hot-path code without any
runtime cost when the env var is unset.
| Consumer | Usage |
|---|---|
endpoint_client/, load_generator/ |
@profile annotations on hot-path functions |
| pytest | Plugin registered via pytest_plugins in tests/conftest.py |