Skip to content
Snippets Groups Projects
Commit f9207038 authored by Ben Gamari's avatar Ben Gamari :turtle:
Browse files

ghc_timings: Introduce it

parent e1b75039
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,7 @@ the scripts are available using `nix-shell`.
profiler.
* `eventlog-sort`: A hack to dump the events from a GHC eventlog with relative
timestamps (in milliseconds).
* `ghc_timings.py`: A small hack to turn `-ddump-timings` output into a Markdown table.
## Release engineering
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import sys
import typing
from typing import Iterator
class Timing(typing.NamedTuple):
phase: str
module: str
time: float
allocd: float
def parse_timings(s: str) -> Iterator[Timing]:
for m in re.finditer(r'!!! ([\w \d]+) \[([\w\d_\.]+)\]: finished in (\d+\.\d+) milliseconds, allocated (\d+\.\d+) megabytes', s):
phase = m.group(1)
module = m.group(2)
time = float(m.group(3))
allocd = float(m.group(4))
yield Timing(phase, module, time, allocd)
def main() -> None:
s = sys.stdin.read()
print('| module | phase | time (ms) | alloc (MB) |')
print('| ------ | ----- | --------- | ---------- |')
for t in parse_timings(s):
print('| {module} | {phase} | {time} | {allocd} |'.format(**t))
if __name__ == '__main__':
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment