Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timing to debug-sym-file.py #109

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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