Statistics
| Branch: | Tag: | Revision:

one / src / sunstone / public / vendor / noVNC / tests / vnc_perf.html @ 5fcb9de8

History | View | Annotate | Download (6.26 KB)

1
<!DOCTYPE html>
2
<html>
3
    <head>
4
        <title>VNC Performance Benchmark</title>
5
        <link rel="stylesheet" href="../include/plain.css">
6
    </head>
7
    <body>
8

    
9
        Passes: <input id='passes' style='width:50' value=3>&nbsp;
10

    
11
        <input id='startButton' type='button' value='Start' style='width:100px'
12
            onclick="do_test();" disabled>&nbsp;
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

    
39
    <script type="text/javascript">
40
        var INCLUDE_URI= "../include/";
41
    </script>
42
    <script src="../include/vnc.js"></script>
43
    <script src="../include/playback.js"></script>
44
    <script src="data/multi.js"></script>
45

    
46
    <script>
47
        var start_time, VNC_frame_data, pass, passes, encIdx,
48
            encOrder = ['raw', 'rre', 'hextile', 'tightpng', 'copyrect'],
49
            encTot = {}, encMin = {}, encMax = {},
50
            passCur, passTot, passMin, passMax;
51

52
        function msg(str) {
53
            console.log(str);
54
            var cell = $D('messages');
55
            cell.innerHTML += str + "\n";
56
            cell.scrollTop = cell.scrollHeight;
57
        }
58
        function dbgmsg(str) {
59
            if (Util.get_logging() === 'debug') {
60
                msg(str);
61
            }
62
        }
63

64
        updateState = function (rfb, state, oldstate, mesg) {
65
            switch (state) {
66
                case 'failed':
67
                case 'fatal':
68
                    msg("noVNC sent '" + state +
69
                        "' state during pass " + pass +
70
                        ", iteration " + iteration +
71
                        " frame " + frame_idx);
72
                    test_state = 'failed';
73
                    break;
74
                case 'loaded':
75
                    $D('startButton').disabled = false;
76
                    break;
77
            }
78
            if (typeof mesg !== 'undefined') {
79
                $D('VNC_status').innerHTML = mesg;
80
            }
81
        }
82

83
        function do_test() {
84
            $D('startButton').value = "Running";
85
            $D('startButton').disabled = true;
86

87
            mode = 'perftest'; // full-speed
88
            passes = $D('passes').value;
89
            pass = 1;
90
            encIdx = 0;
91

92
            // Render each encoding once for each pass
93
            iterations = 1;
94

95
            // Initialize stats counters
96
            for (i = 0; i < encOrder.length; i++) {
97
                enc = encOrder[i];
98
                encTot[i] = 0;
99
                encMin[i] = 2<<23; // Something sufficiently large
100
                encMax[i] = 0;
101
            }
102
            passCur = 0;
103
            passTot = 0;
104
            passMin = 2<<23;
105
            passMax = 0;
106

107
            // Fire away
108
            next_encoding();
109
        }
110

111
        function next_encoding() {
112
            var encName;
113

114
            if (encIdx >= encOrder.length) {
115
                // Accumulate pass stats
116
                if (passCur < passMin) {
117
                    passMin = passCur;
118
                }
119
                if (passCur > passMax) {
120
                    passMax = passCur;
121
                }
122
                msg("Pass " + pass + " took " + passCur + " ms");
123

124
                passCur = 0;
125
                encIdx = 0;
126
                pass += 1;
127
                if (pass > passes) {
128
                    // We are finished
129
                    rfb.get_canvas().stop();   // Shut-off event interception
130
                    $D('startButton').disabled = false;
131
                    $D('startButton').value = "Start";
132
                    finish_passes();
133
                    return; // We are finished, terminate
134
                }
135
            }
136

137
            encName = encOrder[encIdx];
138
            dbgmsg("Rendering pass " + pass + " encoding '" + encName + "'");
139

140
            VNC_frame_data = VNC_frame_data_multi[encName];
141
            iteration = 0;
142
            start_time = (new Date()).getTime();
143

144
            next_iteration();
145
        }
146

147
        // Finished rendering current encoding
148
        function finish() {
149
            var total_time, end_time = (new Date()).getTime();
150
            total_time = end_time - start_time;
151

152
            dbgmsg("Encoding " + encOrder[encIdx] + " took " + total_time + "ms");
153

154
            passCur += total_time;
155
            passTot += total_time;
156

157
            // Accumulate stats
158
            encTot[encIdx] += total_time;
159
            if (total_time < encMin[encIdx]) {
160
                encMin[encIdx] = total_time;
161
            }
162
            if (total_time > encMax[encIdx]) {
163
                encMax[encIdx] = total_time;
164
            }
165

166
            encIdx += 1;
167
            next_encoding();
168
        }
169

170
        function finish_passes() {
171
            var i, enc, avg, passAvg;
172
            msg("STATS (for " + passes + " passes)");
173
            // Encoding stats
174
            for (i = 0; i < encOrder.length; i++) {
175
                enc = encOrder[i];
176
                avg = (encTot[i] / passes).toFixed(1);
177
                msg("  " + enc + ": " + encTot[i] + " ms, " +
178
                    encMin[i] + "/" + avg + "/" + encMax[i] + 
179
                    " (min/avg/max)");
180

181
            }
182
            // Print pass stats
183
            passAvg = (passTot / passes).toFixed(1);
184
            msg("\n  All passes: " + passTot + " ms, " +
185
                passMin + "/" + passAvg + "/" + passMax +
186
                " (min/avg/max)");
187
        }
188

189
        window.onload = function() {
190
            var i, enc;
191
            dbgmsg("Frame lengths:");
192
            for (i = 0; i < encOrder.length; i++) {
193
                enc = encOrder[i];
194
                dbgmsg("  " + enc + ": " + VNC_frame_data_multi[enc].length);
195
            }
196
            rfb = new RFB({'target': $D('VNC_canvas'),
197
                           'updateState': updateState});
198
            rfb.testMode(send_array);
199
        }
200
    </script>
201
</html>