From 05338bccb76e9019f51d1528631c3eecd36026ae Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 8 Nov 2016 14:57:11 +0100 Subject: [PATCH] Log statistics from ComparingUpdateTracker --- common/rfb/ComparingUpdateTracker.cxx | 29 ++++++++++++++++++++++++++- common/rfb/ComparingUpdateTracker.h | 5 +++++ common/rfb/VNCServerST.cxx | 9 +++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/common/rfb/ComparingUpdateTracker.cxx b/common/rfb/ComparingUpdateTracker.cxx index 1d27f3c4..237adc41 100644 --- a/common/rfb/ComparingUpdateTracker.cxx +++ b/common/rfb/ComparingUpdateTracker.cxx @@ -20,12 +20,16 @@ #include #include #include +#include #include using namespace rfb; +static LogWriter vlog("ComparingUpdateTracker"); + ComparingUpdateTracker::ComparingUpdateTracker(PixelBuffer* buffer) - : fb(buffer), oldFb(fb->getPF(), 0, 0), firstCompare(true), enabled(true) + : fb(buffer), oldFb(fb->getPF(), 0, 0), firstCompare(true), + enabled(true), totalPixels(0), missedPixels(0) { changed.assign_union(fb->getRect()); } @@ -72,6 +76,13 @@ bool ComparingUpdateTracker::compare() for (i = rects.begin(); i != rects.end(); i++) compareRect(*i, &newChanged); + changed.get_rects(&rects); + for (i = rects.begin(); i != rects.end(); i++) + totalPixels += i->area(); + newChanged.get_rects(&rects); + for (i = rects.begin(); i != rects.end(); i++) + missedPixels += i->area(); + if (changed.equals(newChanged)) return false; @@ -165,3 +176,19 @@ void ComparingUpdateTracker::compareRect(const Rect& r, Region* newChanged) newChanged->assign_union(temp); } } + +void ComparingUpdateTracker::logStats() +{ + double ratio; + char a[1024], b[1024]; + + siPrefix(totalPixels, "pixels", a, sizeof(a)); + siPrefix(missedPixels, "pixels", b, sizeof(b)); + + ratio = (double)totalPixels / missedPixels; + + vlog.info("%s in / %s out", a, b); + vlog.info("(1:%g ratio)", ratio); + + totalPixels = missedPixels = 0; +} diff --git a/common/rfb/ComparingUpdateTracker.h b/common/rfb/ComparingUpdateTracker.h index fccc2222..e62f2b23 100644 --- a/common/rfb/ComparingUpdateTracker.h +++ b/common/rfb/ComparingUpdateTracker.h @@ -40,12 +40,17 @@ namespace rfb { virtual void enable(); virtual void disable(); + + void logStats(); + private: void compareRect(const Rect& r, Region* newchanged); PixelBuffer* fb; ManagedPixelBuffer oldFb; bool firstCompare; bool enabled; + + rdr::U32 totalPixels, missedPixels; }; } diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx index d5010854..e15cd701 100644 --- a/common/rfb/VNCServerST.cxx +++ b/common/rfb/VNCServerST.cxx @@ -110,6 +110,8 @@ VNCServerST::~VNCServerST() desktop->stop(); } + if (comparer) + comparer->logStats(); delete comparer; } @@ -155,6 +157,10 @@ void VNCServerST::removeSocket(network::Socket* sock) { desktopStarted = false; desktop->stop(); } + + if (comparer) + comparer->logStats(); + return; } } @@ -292,6 +298,9 @@ void VNCServerST::unblockUpdates() void VNCServerST::setPixelBuffer(PixelBuffer* pb_, const ScreenSet& layout) { + if (comparer) + comparer->logStats(); + pb = pb_; delete comparer; comparer = 0; -- 2.39.5