Total counter increments per function from `llvm-profdata show --counts`.
(text: str)
| 136 | |
| 137 | |
| 138 | def parse_counts(text: str) -> dict[str, int]: |
| 139 | """Total counter increments per function from `llvm-profdata show --counts`.""" |
| 140 | out: dict[str, int] = {} |
| 141 | name = None |
| 142 | for line in text.splitlines(): |
| 143 | m = FUNC_RE.match(line) |
| 144 | if m: |
| 145 | name = m.group(1) |
| 146 | continue |
| 147 | if name is None: |
| 148 | continue |
| 149 | s = line.strip() |
| 150 | if s.startswith("Function count:"): |
| 151 | out[name] = out.get(name, 0) + int(s.split(":", 1)[1]) |
| 152 | elif s.startswith("Block counts:"): |
| 153 | vals = s.split(":", 1)[1].strip().strip("[]") |
| 154 | if vals: |
| 155 | out[name] = out.get(name, 0) + sum(int(v) for v in vals.split(",") if v.strip()) |
| 156 | return out |
| 157 | |
| 158 | |
| 159 | def display_name(raw: str) -> str: |
no test coverage detected