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