diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-09-13 16:32:04 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-09-18 17:04:46 -0400 |
commit | 705ec153c5ee3f6d1781647c1bbbfcd7c398c987 (patch) | |
tree | 1dcc75d7e1633df71e4f7d15942cf00a6ee205d6 /scripts/perf/profile_csv.py | |
parent | 725e1b7d6f8ca31705372f9b391a34969f44577b (diff) |
Add script to compare a Frame Profile JSON stats file vs. baseline.
Extract `latest_file()` logic replicated in profile_pretty.py and
profile_csv.py out to logsdir.py, and use for new profile_cmp.py.
(cherry picked from commit 439cfc97a81f221daaf8ba13aa5daa87e8511047)
Diffstat (limited to 'scripts/perf/profile_csv.py')
-rw-r--r-- | scripts/perf/profile_csv.py | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/scripts/perf/profile_csv.py b/scripts/perf/profile_csv.py index 273e3b7434..7a6b2b338e 100644 --- a/scripts/perf/profile_csv.py +++ b/scripts/perf/profile_csv.py @@ -10,17 +10,16 @@ Copyright (c) 2024, Linden Research, Inc. $/LicenseInfo$ """ -import logsdir import json -from pathlib import Path +from logsdir import Error, latest_file, logsdir import sys -class Error(Exception): - pass - def convert(path, totals=True, unused=True, file=sys.stdout): with open(path) as inf: data = json.load(inf) + # print path to sys.stderr in case user is redirecting stdout + print(path, file=sys.stderr) + print('"name", "file1", "file2", "time", "binds", "samples", "triangles"', file=file) if totals: @@ -51,19 +50,8 @@ shaders list to full shaders lines. help="""profile filename to convert (default is most recent)""") args = parser.parse_args(raw_args) - if not args.path: - logs = logsdir.logsdir() - profiles = Path(logs).glob('profile.*.json') - sort = [(p.stat().st_mtime, p) for p in profiles] - sort.sort(reverse=True) - try: - args.path = sort[0][1] - except IndexError: - raise Error(f'No profile.*.json files in {logs}') - # print path to sys.stderr in case user is redirecting stdout - print(args.path, file=sys.stderr) - - convert(args.path, totals=args.totals, unused=args.unused) + convert(args.path or latest_file(logsdir(), 'profile.*.json'), + totals=args.totals, unused=args.unused) if __name__ == "__main__": try: |