4 <title>VNC Performance Benchmark
</title>
8 Passes:
<input id='passes' style='width:
50' value=
3>
10 <input id='startButton' type='button' value='Start' style='width:
100px'
11 onclick=
"do_test();" disabled
>
16 <textarea id=
"messages" style=
"font-size: 9;" cols=
80 rows=
15></textarea>
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>
26 <canvas id=
"VNC_canvas" width=
"640px" height=
"20px">
34 <script type='text/javascript'
35 src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
38 <script type=
"text/javascript">
39 var INCLUDE_URI=
"../";
41 <script src=
"../core/util.js"></script>
42 <script src=
"../app/webutil.js"></script>
45 var fname = WebUtil.getQueryVar('data', null);
47 msg(
"Loading " + fname);
49 // Load supporting scripts
50 WebUtil.load_scripts({
51 'core': [
"base64.js",
"websock.js",
"des.js",
"input/keysym.js",
52 "input/keysymdef.js",
"input/xtscancodes.js",
"input/util.js",
53 "input/keyboard.js",
"input/mouse.js",
"display.js",
"rfb.js",
54 "inflator.js",
"input/vkeys.js",
"input/fixedkeys.js"],
55 'tests': [
"playback.js"],
56 'recordings': [fname]});
58 msg(
"Must specifiy data=FOO.js in query string.");
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;
68 var cell = document.getElementById('messages');
69 cell.textContent += str +
"\n";
70 cell.scrollTop = cell.scrollHeight;
72 function dbgmsg(str) {
73 if (Util.get_logging() === 'debug') {
78 disconnected = function (rfb, reason) {
80 msg(
"noVNC sent '" + state +
81 "' state during pass " + pass +
82 ", iteration " + iteration +
83 " frame " + frame_idx);
84 test_state = 'failed';
89 document.getElementById('startButton').value =
"Running";
90 document.getElementById('startButton').disabled = true;
92 mode = 'perftest'; // full-speed
93 passes = document.getElementById('passes').value;
97 // Render each encoding once for each pass
100 // Initialize stats counters
101 for (i =
0; i < encOrder.length; i++) {
104 encMin[i] =
2<
<23; // Something sufficiently large
116 function next_encoding() {
119 if (encIdx
>= encOrder.length) {
120 // Accumulate pass stats
121 if (passCur < passMin) {
124 if (passCur
> passMax) {
127 msg(
"Pass " + pass +
" took " + passCur +
" ms");
134 // Shut-off event interception
135 rfb.get_mouse().ungrab();
136 rfb.get_keyboard().ungrab();
137 document.getElementById('startButton').disabled = false;
138 document.getElementById('startButton').value =
"Start";
140 return; // We are finished, terminate
144 encName = encOrder[encIdx];
145 dbgmsg(
"Rendering pass " + pass +
" encoding '" + encName +
"'");
147 VNC_frame_data = VNC_frame_data_multi[encName];
149 start_time = (new Date()).getTime();
154 // Finished rendering current encoding
156 var total_time, end_time = (new Date()).getTime();
157 total_time = end_time - start_time;
159 dbgmsg(
"Encoding " + encOrder[encIdx] +
" took " + total_time +
"ms");
161 passCur += total_time;
162 passTot += total_time;
165 encTot[encIdx] += total_time;
166 if (total_time < encMin[encIdx]) {
167 encMin[encIdx] = total_time;
169 if (total_time
> encMax[encIdx]) {
170 encMax[encIdx] = total_time;
177 function finish_passes() {
178 var i, enc, avg, passAvg;
179 msg(
"STATS (for " + passes +
" passes)");
181 for (i =
0; i < encOrder.length; i++) {
183 avg = (encTot[i] / passes).toFixed(
1);
184 msg(
" " + enc +
": " + encTot[i] +
" ms, " +
185 encMin[i] +
"/" + avg +
"/" + encMax[i] +
190 passAvg = (passTot / passes).toFixed(
1);
191 msg(
"\n All passes: " + passTot +
" ms, " +
192 passMin +
"/" + passAvg +
"/" + passMax +
196 window.onscriptsload = function() {
198 dbgmsg(
"Frame lengths:");
199 for (i =
0; i < encOrder.length; i++) {
201 dbgmsg(
" " + enc +
": " + VNC_frame_data_multi[enc].length);
203 document.getElementById('startButton').disabled = false;