]>
Commit | Line | Data |
---|---|---|
a679a97d JM |
1 | <html> |
2 | <head> | |
3 | <title>VNC Performance Benchmark</title> | |
4 | <link rel="stylesheet" href="include/plain.css"> | |
5 | </head> | |
6 | <body> | |
7 | ||
8 | Passes: <input id='passes' style='width:50' value=3> | |
9 | ||
10 | <input id='startButton' type='button' value='Start' style='width:100px' | |
11 | onclick="start();" disabled> | |
12 | ||
13 | <br><br> | |
14 | ||
15 | Results:<br> | |
16 | <textarea id="messages" style="font-size: 9;" cols=80 rows=15></textarea> | |
17 | ||
18 | <br><br> | |
19 | ||
20 | <div id="VNC_screen"> | |
21 | <div id="VNC_status_bar" class="VNC_status_bar" style="margin-top: 0px;"> | |
22 | <table border=0 width=100%><tr> | |
23 | <td><div id="VNC_status">Loading</div></td> | |
24 | </tr></table> | |
25 | </div> | |
26 | <canvas id="VNC_canvas" width="640px" height="20px"> | |
27 | Canvas not supported. | |
28 | </canvas> | |
29 | </div> | |
30 | ||
31 | </body> | |
32 | ||
33 | <!-- | |
34 | <script type='text/javascript' | |
35 | src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script> | |
36 | --> | |
37 | ||
38 | <script src="include/vnc.js"></script> | |
39 | <script src="include/playback.js"></script> | |
40 | <script src="data_multi.js"></script> | |
41 | ||
42 | <script> | |
43 | var start_time, VNC_frame_data, pass, passes, encIdx, | |
44 | encOrder = ['raw', 'rre', 'hextile', 'tightpng', 'copyrect'], | |
45 | encTot = {}, encMin = {}, encMax = {}, | |
46 | passCur, passTot, passMin, passMax; | |
47 | ||
48 | function msg(str) { | |
49 | console.log(str); | |
50 | var cell = $('messages'); | |
51 | cell.innerHTML += str + "\n"; | |
52 | cell.scrollTop = cell.scrollHeight; | |
53 | } | |
54 | function dbgmsg(str) { | |
55 | if (Util.get_logging() === 'debug') { | |
56 | msg(str); | |
57 | } | |
58 | } | |
59 | ||
60 | updateState = function (rfb, state, oldstate, mesg) { | |
61 | switch (state) { | |
62 | case 'failed': | |
63 | case 'fatal': | |
64 | msg("noVNC sent '" + state + | |
65 | "' state during pass " + pass + | |
66 | ", iteration " + iteration + | |
67 | " frame " + frame_idx); | |
68 | test_state = 'failed'; | |
69 | break; | |
70 | case 'loaded': | |
71 | $('startButton').disabled = false; | |
72 | break; | |
73 | } | |
74 | if (typeof mesg !== 'undefined') { | |
75 | $('VNC_status').innerHTML = mesg; | |
76 | } | |
77 | } | |
78 | ||
79 | function start() { | |
80 | $('startButton').value = "Running"; | |
81 | $('startButton').disabled = true; | |
82 | ||
83 | mode = 'perftest'; // full-speed | |
84 | passes = $('passes').value; | |
85 | pass = 1; | |
86 | encIdx = 0; | |
87 | ||
88 | // Render each encoding once for each pass | |
89 | iterations = 1; | |
90 | ||
91 | // Initialize stats counters | |
92 | for (i = 0; i < encOrder.length; i++) { | |
93 | enc = encOrder[i]; | |
94 | encTot[i] = 0; | |
95 | encMin[i] = 2<<23; // Something sufficiently large | |
96 | encMax[i] = 0; | |
97 | } | |
98 | passCur = 0; | |
99 | passTot = 0; | |
100 | passMin = 2<<23; | |
101 | passMax = 0; | |
102 | ||
103 | // Fire away | |
104 | next_encoding(); | |
105 | } | |
106 | ||
107 | function next_encoding() { | |
108 | var encName; | |
109 | ||
110 | if (encIdx >= encOrder.length) { | |
111 | // Accumulate pass stats | |
112 | if (passCur < passMin) { | |
113 | passMin = passCur; | |
114 | } | |
115 | if (passCur > passMax) { | |
116 | passMax = passCur; | |
117 | } | |
118 | msg("Pass " + pass + " took " + passCur + " ms"); | |
119 | ||
120 | passCur = 0; | |
121 | encIdx = 0; | |
122 | pass += 1; | |
123 | if (pass > passes) { | |
124 | // We are finished | |
125 | rfb.get_canvas().stop(); // Shut-off event interception | |
126 | $('startButton').disabled = false; | |
127 | $('startButton').value = "Start"; | |
128 | finish_passes(); | |
129 | return; // We are finished, terminate | |
130 | } | |
131 | } | |
132 | ||
133 | encName = encOrder[encIdx]; | |
134 | dbgmsg("Rendering pass " + pass + " encoding '" + encName + "'"); | |
135 | ||
136 | VNC_frame_data = VNC_frame_data_multi[encName]; | |
137 | iteration = 0; | |
138 | start_time = (new Date()).getTime(); | |
139 | ||
140 | next_iteration(); | |
141 | } | |
142 | ||
143 | // Finished rendering current encoding | |
144 | function finish() { | |
145 | var total_time, end_time = (new Date()).getTime(); | |
146 | total_time = end_time - start_time; | |
147 | ||
148 | dbgmsg("Encoding " + encOrder[encIdx] + " took " + total_time + "ms"); | |
149 | ||
150 | passCur += total_time; | |
151 | passTot += total_time; | |
152 | ||
153 | // Accumulate stats | |
154 | encTot[encIdx] += total_time; | |
155 | if (total_time < encMin[encIdx]) { | |
156 | encMin[encIdx] = total_time; | |
157 | } | |
158 | if (total_time > encMax[encIdx]) { | |
159 | encMax[encIdx] = total_time; | |
160 | } | |
161 | ||
162 | encIdx += 1; | |
163 | next_encoding(); | |
164 | } | |
165 | ||
166 | function finish_passes() { | |
167 | var i, enc, avg, passAvg; | |
168 | msg("STATS (for " + passes + " passes)"); | |
169 | // Encoding stats | |
170 | for (i = 0; i < encOrder.length; i++) { | |
171 | enc = encOrder[i]; | |
172 | avg = (encTot[i] / passes).toFixed(1); | |
173 | msg(" " + enc + ": " + encTot[i] + " ms, " + | |
174 | encMin[i] + "/" + avg + "/" + encMax[i] + | |
175 | " (min/avg/max)"); | |
176 | ||
177 | } | |
178 | // Print pass stats | |
179 | passAvg = (passTot / passes).toFixed(1); | |
180 | msg("\n All passes: " + passTot + " ms, " + | |
181 | passMin + "/" + passAvg + "/" + passMax + | |
182 | " (min/avg/max)"); | |
183 | } | |
184 | ||
185 | window.onload = function() { | |
186 | var i, enc; | |
187 | dbgmsg("Frame lengths:"); | |
188 | for (i = 0; i < encOrder.length; i++) { | |
189 | enc = encOrder[i]; | |
190 | dbgmsg(" " + enc + ": " + VNC_frame_data_multi[enc].length); | |
191 | } | |
192 | rfb = RFB({'target': 'VNC_canvas', | |
193 | 'updateState': updateState}); | |
194 | rfb.testMode(send_array); | |
195 | } | |
196 | </script> | |
197 | </html> |