MCPcopy Index your code
hub / github.com/python/cpython / normalize_trace_output

Function normalize_trace_output

Lib/test/test_dtrace.py:22–44  ·  view source on GitHub ↗

Normalize DTrace output for comparison. DTrace keeps a per-CPU buffer, and when showing the fired probes, buffers are concatenated. So if the operating system moves our thread around, the straight result can be "non-causal". So we add timestamps to the probe firing, sort by that fie

(output)

Source from the content-addressed store, hash-verified

20
21
22def normalize_trace_output(output):
23 """Normalize DTrace output for comparison.
24
25 DTrace keeps a per-CPU buffer, and when showing the fired probes, buffers
26 are concatenated. So if the operating system moves our thread around, the
27 straight result can be "non-causal". So we add timestamps to the probe
28 firing, sort by that field, then strip it from the output"""
29
30 # When compiling with '--with-pydebug', strip '[# refs]' debug output.
31 output = re.sub(r"\[[0-9]+ refs\]", "", output)
32 try:
33 result = [
34 row.split("\t")
35 for row in output.splitlines()
36 if row and not row.startswith('#')
37 ]
38 result.sort(key=lambda row: int(row[0]))
39 result = [row[1] for row in result]
40 return "\n".join(result)
41 except (IndexError, ValueError):
42 raise AssertionError(
43 "tracer produced unparsable output:\n{}".format(output)
44 )
45
46
47class TraceBackend:

Callers 1

run_caseMethod · 0.85

Calls 7

subMethod · 0.45
splitMethod · 0.45
splitlinesMethod · 0.45
startswithMethod · 0.45
sortMethod · 0.45
joinMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…