From 57f42cee84aa5b48eb2db32e8b429796a3d7fb11 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Wed, 23 Feb 2022 01:50:47 +0200 Subject: stats.lua: page 2 - frame timing: use fixed display order Page 2 displays the frame timing info for each type (currently "Fresh" and "Redraw"), but since they're unordered keys of a map, their iteration order and hence their order on screen could (and did) change depending on $things, which was annoying. haasn thinks none of them should be considered more important (and therefore maybe worthy of being displayed on top), so we go with lexicographic order, which currently means that "Fresh" is first. Fixes #9901 --- player/lua/stats.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/player/lua/stats.lua b/player/lua/stats.lua index 4ae5aaa73a..c823541ffc 100644 --- a/player/lua/stats.lua +++ b/player/lua/stats.lua @@ -280,6 +280,14 @@ local function append_property(s, prop, attr, excluded) return append(s, ret, attr) end +local function sorted_keys(t, comp_fn) + local keys = {} + for k,_ in pairs(t) do + keys[#keys+1] = k + end + table.sort(keys, comp_fn) + return keys +end local function append_perfdata(s, dedicated_page) local vo_p = mp.get_property_native("vo-passes") @@ -327,7 +335,8 @@ local function append_perfdata(s, dedicated_page) b("Frame Timings:"), o.prefix_sep, o.font_size * 0.66, "(last/average/peak μs)", o.font_size) - for frame, data in pairs(vo_p) do + for _,frame in ipairs(sorted_keys(vo_p)) do -- ensure fixed display order + local data = vo_p[frame] local f = "%s%s%s{\\fn%s}%s / %s / %s %s%s{\\fn%s}%s%s%s" if dedicated_page then -- cgit v1.2.3