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