blob: de0be08ddb3e7fc150e648181a72053ea89fb960 [file] [log] [blame]
mike@reedtribe.org0e59b792013-05-21 03:24:37 +00001-- just a helper function to dump the parameters, for debugging
mike@reedtribe.org1c5a94f2013-05-16 04:20:23 +00002function tostr(t)
3 local str = ""
4 for k, v in next, t do
mike@reedtribe.org0e59b792013-05-21 03:24:37 +00005 if #str > 0 then
6 str = str .. ", "
7 end
8 if type(k) == "number" then
9 str = str .. "[" .. k .. "] = "
mike@reedtribe.org1c5a94f2013-05-16 04:20:23 +000010 else
mike@reedtribe.org0e59b792013-05-21 03:24:37 +000011 str = str .. tostring(k) .. " = "
12 end
13 if type(v) == "table" then
14 str = str .. "{ " .. tostr(v) .. " }"
15 else
16 str = str .. tostring(v)
mike@reedtribe.org1c5a94f2013-05-16 04:20:23 +000017 end
18 end
19 return str
20end
21
reed@google.comdff7e112013-05-15 19:34:20 +000022canvas = {}
23total = 0
mike@reedtribe.org1c5a94f2013-05-16 04:20:23 +000024
mike@reedtribe.org0e59b792013-05-21 03:24:37 +000025-- called with the parameters to each canvas.draw call
mike@reedtribe.org1c5a94f2013-05-16 04:20:23 +000026function accumulate(t)
mike@reedtribe.org1c5a94f2013-05-16 04:20:23 +000027 total = total + 1
mike@reedtribe.org0e59b792013-05-21 03:24:37 +000028 local n = canvas[t.verb] or 0
29 canvas[t.verb] = n + 1
mike@reedtribe.org1c5a94f2013-05-16 04:20:23 +000030
mike@reedtribe.org0e59b792013-05-21 03:24:37 +000031 -- enable to dump all of the parameters we were sent
32 if false then
33 -- dump the params in t, specifically showing the verb first, which we
34 -- then nil out so it doesn't appear in tostr()
35 io.write(t.verb, " ")
36 t.verb = nil
37 io.write(tostr(t), "\n")
38 end
reed@google.comdff7e112013-05-15 19:34:20 +000039end
mike@reedtribe.org1c5a94f2013-05-16 04:20:23 +000040
mike@reedtribe.org0e59b792013-05-21 03:24:37 +000041-- lua_pictures will call this function after all of the files have been
42-- "accumulated"
reed@google.comdff7e112013-05-15 19:34:20 +000043function summarize()
mike@reedtribe.org1c5a94f2013-05-16 04:20:23 +000044 io.write("total ", total, "\n", tostr(canvas), "\n")
reed@google.comdff7e112013-05-15 19:34:20 +000045end
46