Perf: cache text sizes per baked font, AddRect fast path as 4 rects; run.py --profile + prof.py
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
# Summarise profile.out from `run.py --profile`: top functions by self and inclusive samples, mapped to imgui/*.lua lines
|
||||
import collections, json, os, re, sys, glob
|
||||
path = sys.argv[1] if len(sys.argv) > 1 else "profile.out"
|
||||
tmp = max(glob.glob("/tmp/imgui_test_*/ImGui.linemap.json"), key=os.path.getmtime)
|
||||
lm = json.load(open(tmp))
|
||||
def loc(n):
|
||||
if not n.isdigit(): return "C"
|
||||
n = int(n) - 5 + 2; best = None
|
||||
for start, name in lm:
|
||||
if start <= n: best = (start, name)
|
||||
return "%s:%d" % (best[1], n - best[0] + 1) if best else "?"
|
||||
self_, incl, total = collections.Counter(), collections.Counter(), 0
|
||||
for line in open(path):
|
||||
cnt, stack = line.split(" ", 1); cnt = int(cnt); total += cnt
|
||||
frames = [f.rsplit(",", 2) for f in stack.strip().split(";")]
|
||||
keys = ["%s (%s)" % (f[1] or "?", loc(f[2])) for f in frames]
|
||||
self_[keys[0]] += cnt
|
||||
for k in set(keys): incl[k] += cnt
|
||||
for title, c in (("SELF", self_), ("INCLUSIVE", incl)):
|
||||
print("== %s (%% of %d)" % (title, total))
|
||||
for k, v in c.most_common(int(os.environ.get("N", 30))): print("%5.1f%% %s" % (100 * v / total, k))
|
||||
+2
-1
@@ -33,7 +33,7 @@ def build_run(args, flags):
|
||||
def run(args, extra=""):
|
||||
flags = "ARG_FRAMES=%d; ARG_BIG=%s; ARG_OPEN=%s; ARG_QUIET=%s; %s" % (args.frames, str(args.big).lower(), str(args.open).lower(), str(args.quiet).lower(), extra)
|
||||
try:
|
||||
p = subprocess.run([LUAU, "-O2", "--codegen", build_run(args, flags)], capture_output=True, text=True, timeout=args.timeout)
|
||||
p = subprocess.run([LUAU, "-O2"] + (["--profile=2000"] if args.profile else ["--codegen"]) + [build_run(args, flags)], capture_output=True, text=True, timeout=args.timeout)
|
||||
except subprocess.TimeoutExpired as e:
|
||||
return 124, "TIMEOUT (infinite loop?)\n" + remap((e.stdout or b"").decode(errors="replace"))
|
||||
return p.returncode, remap(p.stdout + p.stderr)
|
||||
@@ -58,6 +58,7 @@ def main():
|
||||
ap.add_argument("--frames", type=int, default=400)
|
||||
ap.add_argument("--main", default=os.path.join(ROOT, "main.client.luau"))
|
||||
ap.add_argument("--big", action="store_true", help="demo window forced to 900x1000")
|
||||
ap.add_argument("--profile", action="store_true", help="sampling profile (no codegen) -> profile.out; see tools/test/prof.py")
|
||||
ap.add_argument("--open", action="store_true", help="force all CollapsingHeader/TreeNode open")
|
||||
ap.add_argument("--timeout", type=int, default=120)
|
||||
ap.add_argument("--quiet", action="store_true", help="no random input (scripted tests drive io themselves)")
|
||||
|
||||
Reference in New Issue
Block a user