From a679a97d1b920b777e369003268f4af70c82acd1 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Sat, 25 Sep 2010 15:50:43 -0500 Subject: [PATCH] Show rect/enc counts, add vnc_perf.html test. - include/rfb.js: Keep track of the number of rects of each encoding type and print them out when we close a connection (if 'info' logging level). - tests/vnc_perf.html: first pass at a noVNC based performance benchmark. - utils/wsproxy.py: Fix the output of the record filename. --- include/rfb.js | 45 ++++++++-- tests/vnc_perf.html | 197 ++++++++++++++++++++++++++++++++++++++++++++ utils/wsproxy.py | 9 +- 3 files changed, 241 insertions(+), 10 deletions(-) create mode 100644 tests/vnc_perf.html diff --git a/include/rfb.js b/include/rfb.js index 3881270..dd07389 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -18,7 +18,7 @@ var that = {}, // Public API interface // Pre-declare private functions used before definitions (jslint) init_vars, updateState, init_msg, normal_msg, recv_message, - framebufferUpdate, + framebufferUpdate, print_stats, pixelFormat, clientEncodings, fbUpdateRequest, keyEvent, pointerEvent, clientCutText, @@ -61,6 +61,7 @@ var that = {}, // Public API interface encHandlers = {}, encNames = {}, + encStats = {}, // [rectCnt, rectCntTot] ws = null, // Web Socket object canvas = null, // Canvas object @@ -216,6 +217,7 @@ function constructor() { for (i=0; i < encodings.length; i+=1) { encHandlers[encodings[i][1]] = encHandlers[encodings[i][0]]; encNames[encodings[i][1]] = encodings[i][0]; + encStats[encodings[i][1]] = [0, 0]; } // Initialize canvas try { @@ -309,6 +311,32 @@ init_vars = function() { FBU.imgQ = []; // TIGHT_PNG image queue mouse_buttonMask = 0; mouse_arr = []; + + // Clear the per connection encoding stats + for (i=0; i < encodings.length; i+=1) { + encStats[encodings[i][1]][0] = 0; + } +}; + +// Print statistics +print_stats = function() { + var i, encName, s; + Util.Info("Encoding stats for this connection:"); + for (i=0; i < encodings.length; i+=1) { + s = encStats[encodings[i][1]]; + if ((s[0] + s[1]) > 0) { + Util.Info(" " + encodings[i][0] + ": " + + s[0] + " rects"); + } + } + Util.Info("Encoding stats since page load:"); + for (i=0; i < encodings.length; i+=1) { + s = encStats[encodings[i][1]]; + if ((s[0] + s[1]) > 0) { + Util.Info(" " + encodings[i][0] + ": " + + s[1] + " rects"); + } + } }; // @@ -440,6 +468,8 @@ updateState = function(state, statusMsg) { }, conf.disconnectTimeout * 1000); } + print_stats(); + // WebSocket.onclose transitions to 'disconnected' break; @@ -944,7 +974,7 @@ normal_msg = function() { }; framebufferUpdate = function() { - var now, hdr, fbu_rt_diff, last_bytes, last_rects, ret = true; + var now, hdr, fbu_rt_diff, ret = true, ctx; if (FBU.rects === 0) { //Util.Debug("New FBU: rQ.slice(0,20): " + rQ.slice(0,20)); @@ -1011,15 +1041,17 @@ framebufferUpdate = function() { } timing.last_fbu = (new Date()).getTime(); - last_bytes = rQlen(); - last_rects = FBU.rects; - // false ret means need more data ret = encHandlers[FBU.encoding](); now = (new Date()).getTime(); timing.cur_fbu += (now - timing.last_fbu); + if (ret) { + encStats[FBU.encoding][0] += 1; + encStats[FBU.encoding][1] += 1; + } + if (FBU.rects === 0) { if (((FBU.width === fb_width) && (FBU.height === fb_height)) || @@ -1058,7 +1090,7 @@ framebufferUpdate = function() { // encHandlers.RAW = function display_raw() { - //Util.Debug(">> display_raw"); + //Util.Debug(">> display_raw (" + rQlen() + " bytes)"); var cur_y, cur_height; @@ -1084,6 +1116,7 @@ encHandlers.RAW = function display_raw() { FBU.rects -= 1; FBU.bytes = 0; } + //Util.Debug("<< display_raw (" + rQlen() + " bytes)"); return true; }; diff --git a/tests/vnc_perf.html b/tests/vnc_perf.html new file mode 100644 index 0000000..8e9c925 --- /dev/null +++ b/tests/vnc_perf.html @@ -0,0 +1,197 @@ + + + VNC Performance Benchmark + + + + + Passes:   + +   + +

+ + Results:
+ + +

+ +
+
+ + +
Loading
+
+ + Canvas not supported. + +
+ + + + + + + + + + + diff --git a/utils/wsproxy.py b/utils/wsproxy.py index 2615c3c..71fe577 100755 --- a/utils/wsproxy.py +++ b/utils/wsproxy.py @@ -101,12 +101,13 @@ def do_proxy(client, target): cpartial = cpartial + buf def proxy_handler(client): - global target_host, target_port, options, rec + global target_host, target_port, options, rec, fname if settings['record']: - handler_msg("opening record file: %s" % settings['record']) - rec = open("%s.%s" % (settings['record'], - settings['handler_id']), 'w+') + fname = "%s.%s" % (settings['record'], + settings['handler_id']) + handler_msg("opening record file: %s" % fname) + rec = open(fname, 'w+') rec.write("var VNC_frame_data = [\n") handler_msg("connecting to: %s:%s" % (target_host, target_port))