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

profile-time: more result reporting, and learn to specify other backends #2072

Merged
merged 2 commits into from
May 8, 2024
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
14 changes: 12 additions & 2 deletions scripts/profile-time.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Use the --number and --repeat options to change the number of iterations.
By default, the script will emit a markdown table with a label pulled from git.

Note: you can run this script against pre-generated .frz files to reduce the startup time.
This script requires the additional dependency `humanize`.

usage:

Expand Down Expand Up @@ -43,6 +43,7 @@
import subprocess

import tqdm
import humanize
import tabulate

import capa.main
Expand Down Expand Up @@ -74,7 +75,7 @@ def main(argv=None):
label += " (dirty)"

parser = argparse.ArgumentParser(description="Profile capa performance")
capa.main.install_common_args(parser, wanted={"format", "os", "input_file", "signatures", "rules"})
capa.main.install_common_args(parser, wanted={"format", "backend", "os", "input_file", "signatures", "rules"})
parser.add_argument("--number", type=int, default=3, help="batch size of profile collection")
parser.add_argument("--repeat", type=int, default=30, help="batch count of profile collection")
parser.add_argument("--label", type=str, default=label, help="description of the profile collection")
Expand Down Expand Up @@ -107,6 +108,15 @@ def do_iteration():
for counter, count in capa.perf.counters.most_common():
logger.debug("perf: counter: %s: %s", counter, count)

print(
tabulate.tabulate(
[(counter, humanize.intcomma(count)) for counter, count in capa.perf.counters.most_common()],
headers=["feature class", "evaluation count"],
tablefmt="github",
)
)
print()

print(
tabulate.tabulate(
[
Expand Down