mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
Add helper program profdemo.lua, running EDuke32's demo profiling N times.
... and displaying statistics afterwards. It was easier to do it this way than porting stat.lua to C and especially adding more logic to the already spaghetti-like demo playback code. git-svn-id: https://svn.eduke32.com/eduke32@3049 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
b6db86ef0a
commit
1ba5ec469b
1 changed files with 63 additions and 0 deletions
63
polymer/eduke32/source/lunatic/profdemo.lua
Executable file
63
polymer/eduke32/source/lunatic/profdemo.lua
Executable file
|
@ -0,0 +1,63 @@
|
|||
#!/usr/bin/env luajit
|
||||
|
||||
local stat = require "stat"
|
||||
|
||||
if (#arg ~= 2) then
|
||||
print("Usage: profdemo.lua <eduke32> <demo_arg>")
|
||||
print("Example: ./profdemo.lua ../../eduke32 -d3:1,8")
|
||||
print(" (for 8 repetitions of demo 3 at 1 frame per gametic)")
|
||||
print("")
|
||||
os.exit(1)
|
||||
end
|
||||
|
||||
local eduke32 = arg[1]
|
||||
local demoarg = arg[2]
|
||||
|
||||
local numrepstr = demoarg:match(",[0-9]+$")
|
||||
local numreps = tonumber(numrepstr and numrepstr:sub(2)) or 1
|
||||
local st = { game=stat.new(), drawrooms=stat.new(), drawrest=stat.new() }
|
||||
local stperx = { game=stat.new(), drawrooms=stat.new(), drawrest=stat.new() }
|
||||
|
||||
local unit, unitperx = {}, {}
|
||||
|
||||
for i=1,numreps do
|
||||
local fh = io.popen(eduke32.." "..demoarg)
|
||||
|
||||
while (true) do
|
||||
local str = fh:read("*l")
|
||||
if (str == nil) then
|
||||
break
|
||||
end
|
||||
|
||||
local NUMRE = "([0-9]+%.[0-9]+)"
|
||||
local UNITRE = "[mu]?s"
|
||||
|
||||
local RE = "(== demo [0-9]+ ([a-z]+) times: "..NUMRE.." ("..UNITRE..") %("..NUMRE.." ("..UNITRE.."/[a-z]+)%))"
|
||||
local wholematch, whatstr, time1, unit1, time2, unit2 = str:match(RE)
|
||||
|
||||
if (wholematch ~= nil) then
|
||||
if (numreps==1) then
|
||||
print(wholematch)
|
||||
else
|
||||
st[whatstr]:add(tonumber(time1))
|
||||
stperx[whatstr]:add(tonumber(time2))
|
||||
|
||||
unit[whatstr] = unit1
|
||||
unitperx[whatstr] = unit2
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if (numreps > 1) then
|
||||
local keys = { "game", "drawrooms", "drawrest" }
|
||||
|
||||
for i=1,#keys do
|
||||
local key = keys[i]
|
||||
if (unit[key] ~= nil) then
|
||||
print("== "..key.." times:")
|
||||
print(" "..tostring(st[key]:getstats()).." ["..unit[key].."]")
|
||||
print(" "..tostring(stperx[key]:getstats()).." ["..unitperx[key].."]")
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue