From e539cb857f36dc0c6ca1f0e4af4d886c93ea1cfe Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 22 Sep 2015 11:09:00 +0200 Subject: [PATCH] Track statistics for CopyRect --- common/rfb/EncodeManager.cxx | 31 +++++++++++++++++++++++++++++++ common/rfb/EncodeManager.h | 1 + 2 files changed, 32 insertions(+) diff --git a/common/rfb/EncodeManager.cxx b/common/rfb/EncodeManager.cxx index 9122cd75..0cd52060 100644 --- a/common/rfb/EncodeManager.cxx +++ b/common/rfb/EncodeManager.cxx @@ -135,6 +135,7 @@ EncodeManager::EncodeManager(SConnection* conn_) : conn(conn_) encoders[encoderZRLE] = new ZRLEEncoder(conn); updates = 0; + memset(©Stats, 0, sizeof(copyStats)); stats.resize(encoderClassMax); for (iter = stats.begin();iter != stats.end();++iter) { StatsVector::value_type::iterator iter2; @@ -170,6 +171,25 @@ void EncodeManager::logStats() vlog.info("Framebuffer updates: %u", updates); + if (copyStats.rects != 0) { + vlog.info(" %s:", "CopyRect"); + + rects += copyStats.rects; + pixels += copyStats.pixels; + bytes += copyStats.bytes; + equivalent += copyStats.equivalent; + + ratio = (double)copyStats.equivalent / copyStats.bytes; + + siPrefix(copyStats.rects, "rects", a, sizeof(a)); + siPrefix(copyStats.pixels, "pixels", b, sizeof(b)); + vlog.info(" %s: %s, %s", "Copies", a, b); + iecPrefix(copyStats.bytes, "B", a, sizeof(a)); + vlog.info(" %*s %s (1:%g ratio)", + (int)strlen("Copies"), "", + a, ratio); + } + for (i = 0;i < stats.size();i++) { // Did this class do anything at all? for (j = 0;j < stats[i].size();j++) { @@ -450,11 +470,22 @@ void EncodeManager::writeCopyRects(const UpdateInfo& ui) std::vector rects; std::vector::const_iterator rect; + beforeLength = conn->getOutStream()->length(); + ui.copied.get_rects(&rects, ui.copy_delta.x <= 0, ui.copy_delta.y <= 0); for (rect = rects.begin(); rect != rects.end(); ++rect) { + int equiv; + + copyStats.rects++; + copyStats.pixels += rect->area(); + equiv = 12 + rect->area() * conn->cp.pf().bpp/8; + copyStats.equivalent += equiv; + conn->writer()->writeCopyRect(*rect, rect->tl.x - ui.copy_delta.x, rect->tl.y - ui.copy_delta.y); } + + copyStats.bytes += conn->getOutStream()->length() - beforeLength; } void EncodeManager::writeSolidRects(Region *changed, const PixelBuffer* pb) diff --git a/common/rfb/EncodeManager.h b/common/rfb/EncodeManager.h index a3df8f74..79db950c 100644 --- a/common/rfb/EncodeManager.h +++ b/common/rfb/EncodeManager.h @@ -112,6 +112,7 @@ namespace rfb { typedef std::vector< std::vector > StatsVector; unsigned updates; + EncoderStats copyStats; StatsVector stats; int activeType; int beforeLength; -- 2.39.5