Skip to content

Commit

Permalink
Add timing to debug-sym-file.py
Browse files Browse the repository at this point in the history
Along with debugging sym file structure, this gives us some information
about how long it took symbolic to parse it.
  • Loading branch information
willkg committed Dec 8, 2023
1 parent 3d36b8c commit a4c31a1
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions bin/debug-sym-file.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,20 @@

# Usage: debug-sym-file.py [SYMFILE]

from contextlib import contextmanager
import os
from time import perf_counter

import click
import symbolic

from eliot.libsymbolic import convert_debug_id, parse_sym_file


@contextmanager
def timer():
start = perf_counter()
yield
click.echo(f"{perf_counter() - start:.3f}s")


@click.command()
Expand All @@ -31,18 +41,14 @@ def sym_file_debug(ctx, symfile):

parts = firstline.split(" ")
click.echo(f"first line: {parts}")
debug_id = convert_debug_id(parts[3])

# Parse with symbolic and create symcache
try:
click.echo("parsing with symbolic ...")
archive = symbolic.Archive.open(symfile)
click.echo("listing objects and making symcaches ...")
for obj in archive.iter_objects():
click.echo(f"* {obj.debug_id}")
obj.make_symcache()
except Exception:
click.echo("symbolic can't parse it")
raise
click.echo("parsing sym file with symbolic ... ", nl=False)
with timer():
with open(symfile, "rb") as fp:
data = fp.read()
parse_sym_file("file.sym", debug_id, data)


if __name__ == "__main__":
Expand Down

0 comments on commit a4c31a1

Please sign in to comment.