Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(921)

Side by Side Diff: tools/lua/bbh_filter.lua

Issue 16948011: Measure tiled rendering. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: SkScalar casts Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/bbh_shootout.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 -- bbh_filter.lua
2 --
3 -- This script outputs info about 'interesting' skp files,
4 -- where the definition of 'interesting' changes but is roughly:
5 -- "Interesting for bounding box hierarchy benchmarks."
6 --
7 -- Currently, the approach is to output, in equal ammounts, the names of the fil es that
8 -- have most commands, and the names of the files that use the least popular com mands.
9
10 function count_entries(table)
11 local count = 0
12 for _,_ in pairs(table) do
13 count = count + 1
14 end
15 return count
16 end
17
18 verbCounts = {}
19
20 function reset_current()
21 -- Data about the skp in transit
22 currentInfo = {
23 fileName = '',
24 verbs = {},
25 numOps = 0
26 }
27 end
28 reset_current()
29
30 numOutputFiles = 10 -- This is per measure.
31 globalInfo = {} -- Saves currentInfo for each file to be used at the end.
32 output = {} -- Stores {fileName, {verb, count}} tables.
33
34 function tostr(t)
35 local str = ""
36 for k, v in next, t do
37 if #str > 0 then
38 str = str .. ", "
39 end
40 if type(k) == "number" then
41 str = str .. "[" .. k .. "] = "
42 else
43 str = str .. tostring(k) .. " = "
44 end
45 if type(v) == "table" then
46 str = str .. "{ " .. tostr(v) .. " }"
47 else
48 str = str .. tostring(v)
49 end
50 end
51 return str
52 end
53
54 function sk_scrape_startcanvas(c, fileName) end
55
56 function sk_scrape_endcanvas(c, fileName)
57 globalInfo[fileName] = currentInfo
58 globalInfo[fileName].fileName = fileName
59 reset_current()
60 end
61
62 function sk_scrape_accumulate(t)
63 -- dump the params in t, specifically showing the verb first, which we
64 -- then nil out so it doesn't appear in tostr()
65 --
66 verbCounts[t.verb] = (verbCounts[t.verb] or 0) + 1
67 currentInfo.verbs[t.verb] = (currentInfo.verbs[t.verb] or 0) + 1
68 currentInfo.numOps = currentInfo.numOps + 1
69
70 t.verb = nil
71 end
72
73 function sk_scrape_summarize()
74 verbWeights = {} -- {verb, weight}, where 0 < weight <= 1
75
76 meta = {}
77 for k,v in pairs(verbCounts) do
78 table.insert(meta, {key=k, value=v})
79 end
80 table.sort(meta, function (a,b) return a.value > b.value; end)
81 maxValue = meta[1].value
82 io.write("-- ==================\n")
83 io.write("------------------------------------------------------------------ \n")
84 io.write("-- Command\t\t\tNumber of calls\t\tPopularity\n")
85 io.write("------------------------------------------------------------------ \n")
86 for k, v in pairs(meta) do
87 verbWeights[v.key] = v.value / maxValue
88
89 -- Poor man's formatting:
90 local padding = "\t\t\t"
91 if (#v.key + 3) < 8 then
92 padding = "\t\t\t\t"
93 end
94 if (#v.key + 3) >= 16 then
95 padding = "\t\t"
96 end
97
98 io.write ("-- ",v.key, padding, v.value, '\t\t\t', verbWeights[v.key], " \n")
99 end
100
101 meta = {}
102 function calculate_weight(verbs)
103 local weight = 0
104 for name, count in pairs(verbs) do
105 weight = weight + (1 / verbWeights[name]) * count
106 end
107 return weight
108 end
109 for n, info in pairs(globalInfo) do
110 table.insert(meta, info)
111 end
112
113 local visitedFiles = {}
114
115 -- Prints out information in lua readable format
116 function output_with_metric(metric_func, description, numOutputFiles)
117 table.sort(meta, metric_func)
118 print(description)
119 local iter = 0
120 for i, t in pairs(meta) do
121 if not visitedFiles[t.fileName] then
122 visitedFiles[t.fileName] = true
123 io.write ("{\nname = \"", t.fileName, "\", \nverbs = {\n")
124 for verb,count in pairs(globalInfo[t.fileName].verbs) do
125 io.write(' ', verb, " = ", count, ",\n")
126 end
127 io.write("}\n},\n")
128
129 iter = iter + 1
130 if iter >= numOutputFiles then
131 break
132 end
133 end
134 end
135 end
136
137 output_with_metric(
138 function(a, b) return calculate_weight(a.verbs) > calculate_weight(b.ver bs); end,
139 "\n-- ================== skps with calling unpopular commands.", 10)
140 output_with_metric(
141 function(a, b) return a.numOps > b.numOps; end,
142 "\n-- ================== skps with the most calls.", 50)
143
144 local count = count_entries(visitedFiles)
145
146 print ("-- Spat", count, "files")
147 end
148
OLDNEW
« no previous file with comments | « tools/bbh_shootout.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698