summaryrefslogtreecommitdiff
path: root/scripts/perf/profile_pretty.py
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-09-12 13:43:36 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-09-12 13:43:36 -0400
commitd60b1f92213ace6a8ab6a4a60cb01a43f45d3955 (patch)
tree448d5d5417ef986b2d736d26f79d4031554fa795 /scripts/perf/profile_pretty.py
parentab3083819793a30911354670a7929b0d3f7c104c (diff)
Add script to convert frame profile JSON file to CSV.
Also slightly refactor profile_pretty.py.
Diffstat (limited to 'scripts/perf/profile_pretty.py')
-rw-r--r--scripts/perf/profile_pretty.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/scripts/perf/profile_pretty.py b/scripts/perf/profile_pretty.py
index ca52fe366a..15b6efd94d 100644
--- a/scripts/perf/profile_pretty.py
+++ b/scripts/perf/profile_pretty.py
@@ -18,19 +18,7 @@ import sys
class Error(Exception):
pass
-def pretty(path=None):
- if not 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:
- 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(path, file=sys.stderr)
-
+def pretty(path):
with open(path) as inf:
data = json.load(inf)
json.dump(data, sys.stdout, indent=4)
@@ -45,6 +33,18 @@ The file produced by the viewer is a single dense line of JSON.
help="""profile filename to pretty-print (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)
+
pretty(args.path)
if __name__ == "__main__":