tstats.js - plan9port - [fork] Plan 9 from user space | |
git clone git://src.adamsgaard.dk/plan9port | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
tstats.js (9923B) | |
--- | |
1 | |
2 biggraph = "arg=rpctotal&graph=diff" | |
3 | |
4 graphname = new Array( | |
5 "arg=*&graph=diskbw", | |
6 "<b>disk</b> bytes/second", | |
7 "arg=*&graph=netbw", | |
8 "<b>network</b> bytes/second", | |
9 "arg=*&graph=iobw", | |
10 "total: <b>disk+net</b> bytes/second", | |
11 | |
12 "arg=apartreadbyte&graph=diff", | |
13 "arena read bytes/second", | |
14 "arg=apartwritebyte&graph=diff", | |
15 "arena write bytes/second", | |
16 | |
17 "arg=bloomfalsemiss&graph=pctdiff&arg2=bloomlookup&max=100", | |
18 "bloom false miss %", | |
19 "arg=bloomhit&graph=pctdiff&arg2=bloomlookup&max=100", | |
20 "bloom hit %", | |
21 "arg=bloommiss&graph=pctdiff&arg2=bloomlookup&max=100", | |
22 "bloom miss %", | |
23 "arg=bloomones&graph=pct&arg2=bloombits&max=100", | |
24 "bloom usage %", | |
25 | |
26 "arg=dcachedirty&graph=pct&arg2=dcachesize&max=100", | |
27 "dcache dirty %", | |
28 "arg=dcachehit&graph=pctdiff&arg2=dcachelookup&max=100", | |
29 "dcache hit %", | |
30 "arg=dcachelookuptime&graph=divdiff&arg2=dcachelookup", | |
31 "dcache lookup time", | |
32 "arg=dcachelookup&graph=diff", | |
33 "dcache lookups/second", | |
34 "arg=dcachewrite&graph=diff", | |
35 "dcache writes/second", | |
36 | |
37 "arg=icachedirty&graph=pct&arg2=icachesize&max=100", | |
38 "icache dirty %", | |
39 "arg=icachehit&graph=pctdiff&arg2=icachelookup&max=100", | |
40 "icache hit %", | |
41 "arg=scachehit&graph=pctdiff&arg2=icachelookup&max=100", | |
42 "scache hit %", | |
43 "arg=icachemiss&graph=pctdiff&arg2=icachelookup&max=100", | |
44 "icache miss %", | |
45 "arg=icachelookuptime&graph=divdiff&arg2=icachelookup", | |
46 "icache lookup time", | |
47 "arg=icacheprefetch&graph=diff", | |
48 "icache prefetches/second", | |
49 "arg=scacheprefetch&graph=diff", | |
50 "scache prefetches/second", | |
51 "arg=icachewrite&graph=diff", | |
52 "icache writes/second", | |
53 | |
54 "arg=isectreadbyte&graph=diff", | |
55 "isect read bytes/second", | |
56 "arg=isectwritebyte&graph=diff", | |
57 "isect write bytes/second", | |
58 | |
59 "arg=lcachehit&graph=pctdiff&arg2=lcachelookup&max=100", | |
60 "lump cache hit %", | |
61 "arg=lcachelookuptime&graph=divdiff&arg2=lcachelookup", | |
62 "lump cache lookup time", | |
63 "arg=lcachewrite&graph=diff", | |
64 "lcache writes/second", | |
65 | |
66 "arg=rpcreadbyte&graph=diff", | |
67 "read RPC bytes/second", | |
68 "arg=rpctotal&graph=diff", | |
69 "RPCs/second", | |
70 "arg=rpcwritebyte&graph=diff", | |
71 "write RPC bytes/second", | |
72 "arg=rpcreadtime&graph=divdiff&arg2=rpcread", | |
73 "read RPC time", | |
74 "arg=rpcwritetime&graph=divdiff&arg2=rpcwrite", | |
75 "write RPC time", | |
76 "arg=rpcreadcachedtime&graph=divdiff&arg2=rpcreadcached", | |
77 "cached read RPC time", | |
78 "arg=rpcreaduncachedtime&graph=divdiff&arg2=rpcreaduncached", | |
79 "uncached read RPC time", | |
80 "arg=rpcwritenewtime&graph=divdiff&arg2=rpcwritenew", | |
81 "fresh write RPC time", | |
82 "arg=rpcwriteoldtime&graph=divdiff&arg2=rpcwriteold", | |
83 "dup write RPC time", | |
84 "arg=cigloadtime&graph=divdiff&arg2=cigload", | |
85 "cig load time", | |
86 | |
87 "arg=sumreadbyte&graph=diff", | |
88 "checksum bytes/second", | |
89 | |
90 "arg=dblockstall", | |
91 "threads stalled: dblock", | |
92 "arg=dcachestall", | |
93 "threads stalled: dcache", | |
94 "arg=icachestall", | |
95 "threads stalled: icache", | |
96 "arg=lumpstall", | |
97 "threads stalled: lump", | |
98 | |
99 "arg=END" | |
100 ) | |
101 | |
102 column0 = new Array( | |
103 "column0", | |
104 "!bandwidth", | |
105 "arg=*&graph=iobw", | |
106 "arg=*&graph=netbw", | |
107 "arg=rpcreadbyte&graph=diff", | |
108 "arg=rpcwritebyte&graph=diff", | |
109 "arg=*&graph=diskbw", | |
110 "arg=isectreadbyte&graph=diff", | |
111 "arg=isectwritebyte&graph=diff", | |
112 "arg=apartreadbyte&graph=diff", | |
113 "arg=apartwritebyte&graph=diff", | |
114 "arg=sumreadbyte&graph=diff", | |
115 | |
116 "!bloom filter", | |
117 "arg=bloomhit&graph=pctdiff&arg2=bloomlookup&max=100", | |
118 "arg=bloommiss&graph=pctdiff&arg2=bloomlookup&max=100", | |
119 "arg=bloomfalsemiss&graph=pctdiff&arg2=bloomlookup&max=100", | |
120 "arg=bloomones&graph=pct&arg2=bloombits&max=100", | |
121 | |
122 "END" | |
123 ) | |
124 | |
125 column1 = new Array( | |
126 "column1", | |
127 "!icache", | |
128 "arg=icachedirty&graph=pct&arg2=icachesize&max=100", | |
129 "arg=icachehit&graph=pctdiff&arg2=icachelookup&max=100", | |
130 "arg=scachehit&graph=pctdiff&arg2=icachelookup&max=100", | |
131 "arg=icachemiss&graph=pctdiff&arg2=icachelookup&max=100", | |
132 "arg=icachewrite&graph=diff", | |
133 "arg=icacheprefetch&graph=diff", | |
134 "arg=scacheprefetch&graph=diff", | |
135 | |
136 "!dcache", | |
137 "arg=dcachedirty&graph=pct&arg2=dcachesize&max=100", | |
138 "arg=dcachehit&graph=pctdiff&arg2=dcachelookup&max=100", | |
139 "arg=dcachelookup&graph=diff", | |
140 "arg=dcachewrite&graph=diff", | |
141 | |
142 "!lump cache", | |
143 "arg=lcachehit&graph=pctdiff&arg2=lcachelookup&max=100", | |
144 "arg=lcachewrite&graph=diff", | |
145 | |
146 "END" | |
147 ) | |
148 | |
149 column2 = new Array( | |
150 "column2", | |
151 | |
152 "!stalls", | |
153 "arg=icachestall", | |
154 "arg=dcachestall", | |
155 "arg=dblockstall", | |
156 "arg=lumpstall", | |
157 | |
158 "!timings", | |
159 "arg=icachelookuptime&graph=divdiff&arg2=icachelookup", | |
160 "arg=lcachelookuptime&graph=divdiff&arg2=lcachelookup", | |
161 "arg=dcachelookuptime&graph=divdiff&arg2=dcachelookup", | |
162 "arg=rpcreadtime&graph=divdiff&arg2=rpcread", | |
163 "arg=rpcwritetime&graph=divdiff&arg2=rpcwrite", | |
164 "arg=rpcreadcachedtime&graph=divdiff&arg2=rpcreadcached", | |
165 "arg=rpcreaduncachedtime&graph=divdiff&arg2=rpcreaduncached", | |
166 "arg=rpcwritenewtime&graph=divdiff&arg2=rpcwritenew", | |
167 "arg=rpcwriteoldtime&graph=divdiff&arg2=rpcwriteold", | |
168 "arg=cigloadtime&graph=divdiff&arg2=cigload", | |
169 | |
170 "END" | |
171 ) | |
172 | |
173 col0info = new Array(column0.length) | |
174 col1info = new Array(column1.length) | |
175 col2info = new Array(column2.length) | |
176 | |
177 function cleardebug() { | |
178 var p = document.getElementById("debug") | |
179 p.innerHTML = "" | |
180 } | |
181 | |
182 function debug(s) { | |
183 var p = document.getElementById("debug") | |
184 if(p.innerHTML == "") | |
185 p.innerHTML = "<a href=\"javascript:cleardebug()\">clear… | |
186 p.innerHTML += "<br>"+s | |
187 } | |
188 | |
189 function Ginfo(y, fill, name) { | |
190 var g = new Object() | |
191 g.y = y | |
192 g.fill = fill | |
193 g.name = name | |
194 return g | |
195 } | |
196 | |
197 function cleartable(t) { | |
198 for(var i=t.rows.length-1; i>=0; i--) | |
199 t.deleteRow(i) | |
200 } | |
201 | |
202 function textofname(name) | |
203 { | |
204 for(var i=0; i<graphname.length; i+=2) | |
205 if(name == graphname[i]) | |
206 return graphname[i+1] | |
207 } | |
208 | |
209 function graphrow(row, span, name, dt, wid, ht, fill, text) { | |
210 var url = "/graph?"+name | |
211 url = url+"&min=0" | |
212 url = url+"&t0=-"+dt | |
213 url = url+"&wid="+wid | |
214 url = url+"&ht="+ht | |
215 url = url+"&fill="+fill | |
216 | |
217 var s = "<td colSpan="+span | |
218 s = s+" valign=bottom" | |
219 s = s+" align=center" | |
220 s = s+" width="+wid | |
221 s = s+" height="+ht | |
222 s = s+" style=\"background-image: url("+url+");\"" | |
223 s = s+">"+textofname(name)+text+"</td>" | |
224 row.innerHTML = s | |
225 } | |
226 | |
227 | |
228 function graphcell(cell, name, dt, wid, ht, fill) { | |
229 cell.vAlign = "bottom" | |
230 cell.align = "center" | |
231 cell.width = wid | |
232 cell.height = ht | |
233 } | |
234 | |
235 function redraw() { | |
236 redrawgraphs() | |
237 redrawsettings() | |
238 } | |
239 | |
240 function redrawgraphs() { | |
241 var t = document.getElementById("statgraphs") | |
242 | |
243 cleartable(t) | |
244 for(var i=0; i<4; i++) | |
245 t.insertRow(i) | |
246 | |
247 graphrow(t.rows[0], 3, biggraph, 86400, 900, 30, 0, " – sh… | |
248 graphrow(t.rows[1], 3, biggraph, 3600, 900, 30, 1, " – sho… | |
249 t.rows[2].innerHTML = "<td height=10></td>" | |
250 | |
251 var r = t.rows[3] | |
252 graphtable(r.insertCell(0), column0, col0info, 0) | |
253 graphtable(r.insertCell(1), column1, col1info, 2) | |
254 graphtable(r.insertCell(2), column2, col2info, 4) | |
255 } | |
256 | |
257 function graphtable(bigcell, list, infolist, fill) { | |
258 bigcell.innerHTML = "<table id=\""+list[0]+"\"></table>" | |
259 bigcell.vAlign = "top" | |
260 var t = document.getElementById(list[0]) | |
261 t.onclick = columnclick | |
262 | |
263 for(var i=1; i<list.length; i++){ | |
264 var r = t.insertRow(t.rows.length) | |
265 name = list[i] | |
266 infolist[i] = Ginfo(t.offsetHeight, fill, name) | |
267 if(name == "END") | |
268 break | |
269 if(name.substring(0,1) == "!"){ | |
270 name = name.substring(1) | |
271 if(i > 1){ | |
272 r.innerHTML = "<td height=10></td>" | |
273 r = t.insertRow(t.rows.length) | |
274 } | |
275 r.innerHTML = "<td align=center><b>"+name+"</b>" | |
276 }else{ | |
277 graphrow(r, 1, name, 600, 300, 30, fill++, "") | |
278 } | |
279 } | |
280 } | |
281 | |
282 function xpos(obj) { | |
283 var x = 0 | |
284 if(obj.fixedx) | |
285 return obj.fixedx | |
286 if(obj.offsetParent){ | |
287 while(obj.offsetParent){ | |
288 x += obj.offsetLeft | |
289 obj = obj.offsetParent | |
290 } | |
291 }else if(obj.x) | |
292 x = obj.x | |
293 return x | |
294 } | |
295 | |
296 function ypos(obj) { | |
297 var y = 0 | |
298 if(obj.fixedy) | |
299 return obj.fixedy | |
300 if(obj.offsetParent){ | |
301 while(obj.offsetParent){ | |
302 y += obj.offsetTop | |
303 obj = obj.offsetParent | |
304 } | |
305 }else if(obj.y) | |
306 y = obj.y | |
307 return y | |
308 } | |
309 | |
310 function scrollleft() { | |
311 return document.body.scrollLeft | |
312 } | |
313 | |
314 function scrolltop() { | |
315 return document.body.scrollTop | |
316 } | |
317 | |
318 function columnclick(e) { | |
319 if(e.which && e.which != 1) | |
320 return; | |
321 var g = findgraph(scrollleft()+e.clientX, scrolltop()+e.clientY) | |
322 if(g && g.name.substring(0,1) != "!"){ | |
323 biggraph = g.name | |
324 var t = document.getElementById("statgraphs") | |
325 graphrow(t.rows[0], 3, biggraph, 86400, 900, 30, 0, " &n… | |
326 graphrow(t.rows[1], 3, biggraph, 3600, 900, 30, 1, " &nd… | |
327 } | |
328 } | |
329 | |
330 function findgraph(x, y) { | |
331 var g | |
332 | |
333 if(g = findgraphin(x, y, "column2", col2info)) | |
334 return g | |
335 if(g = findgraphin(x, y, "column1", col1info)) | |
336 return g | |
337 if(g = findgraphin(x, y, "column0", col0info)) | |
338 return g | |
339 return | |
340 } | |
341 | |
342 function findgraphin(x, y, tname, info) { | |
343 var t = document.getElementById(tname) | |
344 if(x < xpos(t)) | |
345 return | |
346 y = y - ypos(t) | |
347 for(var i=info.length-2; i>=1; i--){ | |
348 if(y > info[i].y) | |
349 return info[i] | |
350 } | |
351 return | |
352 } | |
353 | |
354 function setof(name, val, list) { | |
355 var s = "" | |
356 for(var i=0; i<list.length; i++){ | |
357 if(val == list[i]) | |
358 s = s+" <b>"+val+"</b>" | |
359 else | |
360 s = s+" <a href=\"javascript:set('"+name+"', '"+… | |
361 } | |
362 return s | |
363 } | |
364 | |
365 function loglinks(list) { | |
366 var s = "" | |
367 for(var i=0; i<list.length; i++){ | |
368 s = s+" <a href=\"/log?log="+list[i]+"\">"+list[i]+"</a>" | |
369 } | |
370 return s | |
371 } | |
372 | |
373 first = 1 | |
374 function redrawsettings() { | |
375 if(first){ | |
376 loadsettings() | |
377 first = 0 | |
378 } | |
379 var s = "" | |
380 s = s+"<font size=-1>\n" | |
381 s = s+"logging:"+setof("logging", logging, loggingchoices) | |
382 s = s+" " | |
383 s = s+"stats:"+setof("stats", stats, statschoices) | |
384 s = s+"\n<p/>\n" | |
385 s = s+"compression:"+setof("compress", compress, compresschoices… | |
386 s = s+"<br>"+setof("compress", compress, compresschoices2) | |
387 s = s+"\n<p/>\n" | |
388 s = s+"<a href=/index>index</a> | <a href=/storage>storage</a> |… | |
389 s = s+"log:"+loglinks(logs) | |
390 s = s+"</font>" | |
391 document.getElementById("settings").innerHTML = s | |
392 } | |
393 | |
394 function set(name, value) { | |
395 eval(name+"= \""+value+"\"") | |
396 redrawsettings() | |
397 // Works in FireFox, not in Safari | |
398 parent.hidden.location.href = "/set?name="+name+"&value="+value | |
399 } |