-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathprofiler.html
88 lines (76 loc) · 2.86 KB
/
profiler.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!doctype html>
<meta charset=utf-8>
<title> Profiling Tree Systems </title>
<style>
html { font-family: monospace; }
table { width: 100%; border-spacing: 0px 2px; }
tr { background: #faf7fe; }
th, td { width: 50%; }
th { color: #aaa; text-align: right; padding-right: 1em; }
span.unit { color: #aaa; }
</style>
<form id=param action='javascript:void 0'>
<label> Path: <input id=path></label>
<button type=submit> Get data for that path </button>
</form>
<div id=data></div>
<script src=lib/js/scout.js?plug=none></script>
<script>
function esc(str) { return str.replace('<', '<'); }
var formatData = {
raw: function(data, unit) {
return data + (unit ? ' <span class=unit>' + unit + '</span>' : '');
},
seconds: function(data, unit) {
var s = parseInt(data) % 60,
m = parseInt(data / 60) % 60,
h = parseInt(data / 3600) % 24,
d = parseInt(data / 86400);
function digits(n) {
return (n < 10 ? '0' + n : n);
};
return d + ' <span class=unit>days</span> ' +
digits(h) + '<span class=unit>:</span class=unit>' +
digits(m) + '<span class=unit>:</span class=unit>' +
digits(s);
},
bytes: function(data, unit) {
console.log(data,unit);
var units = ['','k','M','G','T','P','E','Z','Y'];
for (var i = 0, max = 1 ; i < units.length ; i++) {
if (data < max * 1024)
return parseInt(100 * data / max) / 100 + ' <span class=unit>' + units[i] + 'B</span>';
max *= 1024;
}
}
};
function templateRow(header, data, unit) {
var html = '<tr><th>' + esc(header) + '<td>', data = esc('' + data);
return html + (formatData[unit] || formatData.raw)(data, unit);
}
function templateSection(name, data) {
return '<h1>' + esc(name) + '</h1><table>' + data.map(function (row) {
return templateRow(row.doc, row.data, row.unit);
}).join('') + '</table>';
}
function templateProf(data) {
var str = '';
for (var e in data) {
str += templateSection(e, data[e]);
}
return str;
}
var dataElt = null;
function ask (params) {
params.action = 'profiler';
params.data = {'File system': {path:Scout('#path').value}};
params.resp = function(resp) {
dataElt = dataElt || document.getElementById('data');
dataElt.innerHTML = templateProf(resp);
};
}
addEventListener('load', Scout.send(ask), false);
Scout('#param').on('submit', ask);
</script>
<!-- Google Analytics -->
<script>var _gaq=_gaq||[];_gaq.push(['_setAccount','UA-27876347-1']);_gaq.push(['_trackPageview']);(function(){var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;ga.src=('https:'==document.location.protocol?'https://ssl':'http://www')+'.google-analytics.com/ga.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);})()</script>