Log inGet started
Package

LookCost.module

Newest version

README.md

LookCost

Measures what a style look costs per frame, as the engine's own GPU time (timestamp queries, every pass styleKit and its blocks add, medians summed) and CPU time (styleKit's own per-frame Lua work, and the engine thread's CPU mean from profiler.cost, thread clock rather than wall clock), with a few thousand things in view.

Run it in play:

local LookCost = require("showcase.LookCost")
local StyleKit = require("~styleKit.StyleKit")
LookCost.crowd(2500)            -- 2500 boxes and balls in front of the player
print(LookCost.report())        -- every comic look, the low tier, and the panel page with 0 to 3 extra views
-- whole-frame change, alternated: median GPU (own) and engine-thread CPU change over 10 rounds
local r = LookCost.onOff(function() StyleKit.applyLook("goldenAgeFourColour") end, function() StyleKit.clear() end, 10, 3)
print(r.gpuOwnDelta, r.cpuDelta, r.stackPasses)
LookCost.clearCrowd()

LookCost.measure(lookIdOrEntries, after?) measures one look. LookCost.onOff(on, off, rounds, seconds?) alternates any two states and returns the median change in whole-frame GPU and engine-thread CPU with every round, which is what to use on a busy machine (single readings swing by several ms of CPU). The numbers in the package READMEs' "Measured cost" sections come from this module.