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