MCPcopy Create free account
hub / github.com/FastLED/FastLED / get_header_times

Method get_header_times

ci/perf/compile_perf.py:165–237  ·  view source on GitHub ↗

Get header parse times with nesting information. IMPORTANT: Returns CUMULATIVE time (total time including all nested includes). This is the full duration from when the compiler starts processing the header until it finishes, including all headers it includes recursi

(self, max_depth: int = 2)

Source from the content-addressed store, hash-verified

163 return Path(path).name
164
165 def get_header_times(self, max_depth: int = 2) -> dict[str, Any]:
166 """
167 Get header parse times with nesting information.
168
169 IMPORTANT: Returns CUMULATIVE time (total time including all nested includes).
170 This is the full duration from when the compiler starts processing the header
171 until it finishes, including all headers it includes recursively.
172
173 Returns:
174 Dict mapping header name to:
175 {
176 'time': float, # CUMULATIVE milliseconds (includes nested headers)
177 'path': str, # full path
178 'depth': int, # nesting level
179 'parent': str, # parent header
180 'children': List[str] # child headers
181 }
182 """
183 headers: dict[str, dict[str, Any]] = {}
184
185 # Sort events by timestamp
186 sorted_sources = sorted(self.source_events, key=lambda e: e.get("ts", 0))
187
188 # Build parent-child relationships
189 stack: list[tuple[str, int, int]] = [] # (path, start_ts, end_ts)
190
191 for event in sorted_sources:
192 path = event.get("args", {}).get("detail", "")
193 if not path:
194 continue
195
196 ts = event.get("ts", 0)
197 dur = event.get("dur", 0)
198 end_ts = ts + dur
199
200 # Find parent (last event that contains this timestamp)
201 parent = None
202 depth = 0
203
204 # Clean up stack (remove events that have ended)
205 while stack and stack[-1][2] <= ts:
206 stack.pop()
207
208 if stack:
209 parent = stack[-1][0]
210 depth = len(stack)
211
212 stack.append((path, ts, end_ts))
213
214 header_name = self._extract_header_name(path)
215
216 if header_name not in headers:
217 headers[header_name] = {
218 "time": dur / 1000.0,
219 "path": path,
220 "depth": depth,
221 "parent": self._extract_header_name(parent) if parent else None,
222 "children": [],

Callers 2

get_fastled_headersMethod · 0.95
build_header_treeMethod · 0.95

Calls 4

_extract_header_nameMethod · 0.95
getMethod · 0.45
popMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected