]>
Commit | Line | Data |
---|---|---|
f8990704 | 1 | <!DOCTYPE html> |
a679a97d JM |
2 | <html> |
3 | <head> | |
4 | <title>VNC Performance Benchmark</title> | |
a679a97d JM |
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' | |
f8990704 | 11 | onclick="do_test();" disabled> |
a679a97d JM |
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 | <!-- | |
ae510306 | 34 | <script type='text/javascript' |
a679a97d JM |
35 | src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script> |
36 | --> | |
37 | ||
5e55378b | 38 | <script type="text/javascript"> |
ae510306 | 39 | var INCLUDE_URI= "../"; |
35785a90 | 40 | // TODO: Data file should override |
4ee55e01 | 41 | var VNC_frame_encoding = "binary"; |
5e55378b | 42 | </script> |
ae510306 SR |
43 | <script src="../core/util.js"></script> |
44 | <script src="../app/webutil.js"></script> | |
a679a97d JM |
45 | |
46 | <script> | |
4ee55e01 SR |
47 | var fname = WebUtil.getQueryVar('data', null); |
48 | if (fname) { | |
49 | msg("Loading " + fname); | |
50 | ||
51 | // Load supporting scripts | |
72bdd06e | 52 | WebUtil.load_scripts({ |
bd5340c7 SR |
53 | 'core': ["base64.js", "websock.js", "des.js", "input/keysym.js", |
54 | "input/keysymdef.js", "input/xtscancodes.js", "input/util.js", | |
55 | "input/devices.js", "display.js", "rfb.js", "inflator.js"], | |
ae510306 SR |
56 | 'tests': ["playback.js"], |
57 | 'recordings': [fname]}); | |
4ee55e01 SR |
58 | } else { |
59 | msg("Must specifiy data=FOO.js in query string."); | |
60 | } | |
6f4b1e40 | 61 | |
a679a97d JM |
62 | var start_time, VNC_frame_data, pass, passes, encIdx, |
63 | encOrder = ['raw', 'rre', 'hextile', 'tightpng', 'copyrect'], | |
64 | encTot = {}, encMin = {}, encMax = {}, | |
65 | passCur, passTot, passMin, passMax; | |
66 | ||
67 | function msg(str) { | |
68 | console.log(str); | |
ae510306 | 69 | var cell = document.getElementById('messages'); |
a679a97d JM |
70 | cell.innerHTML += str + "\n"; |
71 | cell.scrollTop = cell.scrollHeight; | |
72 | } | |
73 | function dbgmsg(str) { | |
74 | if (Util.get_logging() === 'debug') { | |
75 | msg(str); | |
76 | } | |
77 | } | |
78 | ||
79 | updateState = function (rfb, state, oldstate, mesg) { | |
80 | switch (state) { | |
81 | case 'failed': | |
82 | case 'fatal': | |
83 | msg("noVNC sent '" + state + | |
84 | "' state during pass " + pass + | |
85 | ", iteration " + iteration + | |
86 | " frame " + frame_idx); | |
87 | test_state = 'failed'; | |
88 | break; | |
89 | case 'loaded': | |
ae510306 | 90 | document.getElementById('startButton').disabled = false; |
a679a97d JM |
91 | break; |
92 | } | |
93 | if (typeof mesg !== 'undefined') { | |
ae510306 | 94 | document.getElementById('VNC_status').innerHTML = mesg; |
a679a97d JM |
95 | } |
96 | } | |
97 | ||
f8990704 | 98 | function do_test() { |
ae510306 SR |
99 | document.getElementById('startButton').value = "Running"; |
100 | document.getElementById('startButton').disabled = true; | |
a679a97d JM |
101 | |
102 | mode = 'perftest'; // full-speed | |
ae510306 | 103 | passes = document.getElementById('passes').value; |
a679a97d JM |
104 | pass = 1; |
105 | encIdx = 0; | |
106 | ||
107 | // Render each encoding once for each pass | |
108 | iterations = 1; | |
109 | ||
110 | // Initialize stats counters | |
111 | for (i = 0; i < encOrder.length; i++) { | |
112 | enc = encOrder[i]; | |
113 | encTot[i] = 0; | |
114 | encMin[i] = 2<<23; // Something sufficiently large | |
115 | encMax[i] = 0; | |
116 | } | |
117 | passCur = 0; | |
118 | passTot = 0; | |
119 | passMin = 2<<23; | |
120 | passMax = 0; | |
121 | ||
122 | // Fire away | |
123 | next_encoding(); | |
124 | } | |
125 | ||
126 | function next_encoding() { | |
127 | var encName; | |
128 | ||
129 | if (encIdx >= encOrder.length) { | |
130 | // Accumulate pass stats | |
131 | if (passCur < passMin) { | |
132 | passMin = passCur; | |
133 | } | |
134 | if (passCur > passMax) { | |
135 | passMax = passCur; | |
136 | } | |
137 | msg("Pass " + pass + " took " + passCur + " ms"); | |
138 | ||
139 | passCur = 0; | |
140 | encIdx = 0; | |
141 | pass += 1; | |
142 | if (pass > passes) { | |
143 | // We are finished | |
13106063 JM |
144 | // Shut-off event interception |
145 | rfb.get_mouse().ungrab(); | |
146 | rfb.get_keyboard().ungrab(); | |
ae510306 SR |
147 | document.getElementById('startButton').disabled = false; |
148 | document.getElementById('startButton').value = "Start"; | |
a679a97d JM |
149 | finish_passes(); |
150 | return; // We are finished, terminate | |
151 | } | |
152 | } | |
153 | ||
154 | encName = encOrder[encIdx]; | |
155 | dbgmsg("Rendering pass " + pass + " encoding '" + encName + "'"); | |
156 | ||
157 | VNC_frame_data = VNC_frame_data_multi[encName]; | |
158 | iteration = 0; | |
159 | start_time = (new Date()).getTime(); | |
160 | ||
161 | next_iteration(); | |
162 | } | |
163 | ||
164 | // Finished rendering current encoding | |
165 | function finish() { | |
166 | var total_time, end_time = (new Date()).getTime(); | |
167 | total_time = end_time - start_time; | |
168 | ||
169 | dbgmsg("Encoding " + encOrder[encIdx] + " took " + total_time + "ms"); | |
170 | ||
171 | passCur += total_time; | |
172 | passTot += total_time; | |
173 | ||
174 | // Accumulate stats | |
175 | encTot[encIdx] += total_time; | |
176 | if (total_time < encMin[encIdx]) { | |
177 | encMin[encIdx] = total_time; | |
178 | } | |
179 | if (total_time > encMax[encIdx]) { | |
180 | encMax[encIdx] = total_time; | |
181 | } | |
182 | ||
183 | encIdx += 1; | |
184 | next_encoding(); | |
185 | } | |
186 | ||
187 | function finish_passes() { | |
188 | var i, enc, avg, passAvg; | |
189 | msg("STATS (for " + passes + " passes)"); | |
190 | // Encoding stats | |
191 | for (i = 0; i < encOrder.length; i++) { | |
192 | enc = encOrder[i]; | |
193 | avg = (encTot[i] / passes).toFixed(1); | |
194 | msg(" " + enc + ": " + encTot[i] + " ms, " + | |
ae510306 | 195 | encMin[i] + "/" + avg + "/" + encMax[i] + |
a679a97d JM |
196 | " (min/avg/max)"); |
197 | ||
198 | } | |
199 | // Print pass stats | |
200 | passAvg = (passTot / passes).toFixed(1); | |
201 | msg("\n All passes: " + passTot + " ms, " + | |
202 | passMin + "/" + passAvg + "/" + passMax + | |
203 | " (min/avg/max)"); | |
204 | } | |
205 | ||
6f4b1e40 | 206 | window.onscriptsload = function() { |
a679a97d JM |
207 | var i, enc; |
208 | dbgmsg("Frame lengths:"); | |
209 | for (i = 0; i < encOrder.length; i++) { | |
210 | enc = encOrder[i]; | |
211 | dbgmsg(" " + enc + ": " + VNC_frame_data_multi[enc].length); | |
212 | } | |
ae510306 | 213 | document.getElementById('startButton').disabled = false; |
a679a97d JM |
214 | } |
215 | </script> | |
216 | </html> |