Same sites, two platforms: what does one retain that the other does not? Raw addresses differ between binaries, so sites are matched by symbol name when --binary is given (the same binary for both runs) and by address otherwise.
(path_a, path_b, top, binary=None)
| 146 | |
| 147 | |
| 148 | def diff(path_a, path_b, top, binary=None): |
| 149 | """Same sites, two platforms: what does one retain that the other does not? |
| 150 | Raw addresses differ between binaries, so sites are matched by symbol name |
| 151 | when --binary is given (the same binary for both runs) and by address otherwise.""" |
| 152 | summaries_a, series_a = load_profile(path_a) |
| 153 | _, series_b = load_profile(path_b) |
| 154 | names = load_symbols(binary, summaries_a, set(series_a) | set(series_b)) |
| 155 | rows = [] |
| 156 | for site, samples in series_a.items(): |
| 157 | a_live = samples[-1]["live_bytes"] |
| 158 | b_live = series_b[site][-1]["live_bytes"] if site in series_b else 0 |
| 159 | if a_live - b_live > 0: |
| 160 | rows.append((a_live - b_live, a_live, b_live, site)) |
| 161 | rows.sort(key=lambda row: row[0], reverse=True) |
| 162 | print(f"=== {path_a} minus {path_b} (top {top}) ===") |
| 163 | for delta, a_live, b_live, site in rows[:top]: |
| 164 | print(f" +{delta/1048576:7.2f} MB A={a_live/1048576:.2f} MB B={b_live/1048576:.2f} MB") |
| 165 | print(f" {names.get(site, site)}") |
| 166 | |
| 167 | |
| 168 | def main(): |
no test coverage detected