Classes
HighlightTiming
5
▼
Timing data for a single highlight call.
HighlightTiming
5
▼
Timing data for a single highlight call.
Attributes
| Name | Type | Description |
|---|---|---|
language |
str
|
Language that was highlighted. |
lexer_ms |
float
|
Lexer tokenization time in milliseconds. |
formatter_ms |
float
|
Formatter formatting time in milliseconds. |
total_ms |
float
|
Total highlight time in milliseconds. |
code_length |
int
|
Length of the code string in characters. |
HighlightAccumulator
6
▼
Accumulated metrics during syntax highlighting.
Opt-in profiling for debugging slow highlighting.
…
HighlightAccumulator
6
▼
Accumulated metrics during syntax highlighting.
Opt-in profiling for debugging slow highlighting. Zero overhead when disabled (get_accumulator() returns None).
Attributes
| Name | Type | Description |
|---|---|---|
calls |
list[HighlightTiming]
|
List of per-call timing data. |
start_time |
float
|
Profiling start timestamp. |
Methods
total_duration_ms
0
float
▼
Total profiling duration in milliseconds.
property
total_duration_ms
0
float
▼
def total_duration_ms(self) -> float
Returns
float
call_count
0
int
▼
Total number of highlight calls recorded.
property
call_count
0
int
▼
def call_count(self) -> int
Returns
int
record
5
▼
Record a highlight call.
record
5
▼
def record(self, language: str, lexer_ms: float, formatter_ms: float, total_ms: float, code_length: int) -> None
Parameters
| Name | Type | Description |
|---|---|---|
language |
— |
Language that was highlighted. |
lexer_ms |
— |
Lexer tokenization time in milliseconds. |
formatter_ms |
— |
Formatter formatting time in milliseconds. |
total_ms |
— |
Total highlight time in milliseconds. |
code_length |
— |
Length of the code string. |
summary
0
dict[str, Any]
▼
Get summary of highlight metrics.
summary
0
dict[str, Any]
▼
def summary(self) -> dict[str, Any]
Returns
dict[str, Any]
Dict with total_ms, call_count, calls, and by_language breakdown.
Functions
get_accumulator
0
HighlightAccumulator | N…
▼
Get current accumulator (None if profiling disabled).
get_accumulator
0
HighlightAccumulator | N…
▼
def get_accumulator() -> HighlightAccumulator | None
Returns
HighlightAccumulator | None
profiled_highlight
0
Iterator[HighlightAccumu…
▼
Context manager for profiled highlighting.
Creates a HighlightAccumulator and …
profiled_highlight
0
Iterator[HighlightAccumu…
▼
def profiled_highlight() -> Iterator[HighlightAccumulator]
Context manager for profiled highlighting.
Creates a HighlightAccumulator and makes it available via get_accumulator() for the duration of the with block. The highlight() function checks for the accumulator and records metrics automatically.
Returns
Iterator[HighlightAccumulator]