Skip to content

Commit

Permalink
Flush out rendering after each performance test
Browse files Browse the repository at this point in the history
There might be operations pending in the render queue. Make sure
these are fully handled before we consider the test run over.
  • Loading branch information
CendioOssman committed Dec 9, 2016
1 parent e12e275 commit 18e9609
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions tests/playback.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ var rfb, mode, test_state, frame_idx, frame_length,
iteration, iterations, istart_time, encoding,

// Pre-declarations for jslint
send_array, next_iteration, queue_next_packet, do_packet, enable_test_mode;
send_array, next_iteration, end_iteration, queue_next_packet,
do_packet, enable_test_mode;

// Override send_array
send_array = function (arr) {
Expand Down Expand Up @@ -112,6 +113,20 @@ next_iteration = function () {

};

end_iteration = function () {
if (rfb._display.pending()) {
rfb._display.set_onFlush(function () {
if (rfb._flushing) {
rfb._onFlush();
}
end_iteration();
});
rfb._display.flush();
} else {
next_iteration();
}
};

queue_next_packet = function () {
var frame, foffset, toffset, delay;
if (test_state !== 'running') { return; }
Expand All @@ -125,12 +140,12 @@ queue_next_packet = function () {

if (frame === 'EOF') {
Util.Debug("Finished, found EOF");
next_iteration();
end_iteration();
return;
}
if (frame_idx >= frame_length) {
Util.Debug("Finished, no more frames");
next_iteration();
end_iteration();
return;
}

Expand All @@ -151,6 +166,16 @@ queue_next_packet = function () {
var bytes_processed = 0;

do_packet = function () {
// Avoid having an excessive queue buildup
if (rfb._flushing && (mode !== 'realtime')) {
rfb._display.set_onFlush(function () {
rfb._display.set_onFlush(rfb._onFlush.bind(rfb));
rfb._onFlush();
do_packet();
});
return;
}

//Util.Debug("Processing frame: " + frame_idx);
var frame = VNC_frame_data[frame_idx],
start = frame.indexOf('{', 1) + 1;
Expand Down

0 comments on commit 18e9609

Please sign in to comment.