try to track this thing down better
[QuestHelper.git] / bst_pre.lua
blob6568761fc5909a4d68345e3d46b04f6dd1dbfe40
1 --[====[
3 -- Crazy profiling madness
4 -- sed -i s/{/QH_RegisterTable{/g `ls | grep lua | grep -v static`
6 -- This is grimness so we can just apply the filter indiscriminately
8 local QHRT
9 QH_RegisterTable = function(...) return QHRT(...) end
11 local QH_RegisterTable = function(...) return ... end
13 QHT_Types = setmetatable({}, {__mode="k"})
15 QHRT = function(tab, override, tag)
16 if not override then assert(not QHT_Types[tab]) end
17 QHT_Types[tab] = tag or string.gsub(debugstack(2, 1, 1), "\n.*", "")
18 return tab
19 end
20 function QH_CTprint(sum)
21 local typ = {}
22 for k, v in pairs(sum) do
23 table.insert(typ, {k = k, v = v})
24 end
26 table.sort(typ, function(a, b) return a.v < b.v end)
28 for _, v in pairs(typ) do
29 if v.v > 0 then
30 print(v.v, v.k)
31 end
32 end
33 end
34 function QH_CTacu()
35 local sum = {}
36 for k, v in pairs(QHT_Types) do
37 sum[v] = (sum[v] or 0) + 1
38 end
40 return sum
41 end
43 function QH_CheckTables()
44 local before = QH_CTacu()
45 collectgarbage("collect")
46 local after = QH_CTacu()
48 local sum = {}
49 for k, v in pairs(before) do sum[k] = (before[k] or 0) - (after[k] or 0) end
50 for k, v in pairs(after) do sum[k] = (before[k] or 0) - (after[k] or 0) end
51 QH_CTprint(sum)
52 end
53 function QH_PrintTables()
54 QH_CTprint(QH_CTacu())
55 end
57 ]====]
59 QuestHelper_File = {}
60 QuestHelper_Loadtime = {}
61 QuestHelper_File["bst_pre.lua"] = "Development Version"
62 QuestHelper_Loadtime["bst_pre.lua"] = GetTime()