aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2016-11-08 14:57:11 +0100
committerPierre Ossman <ossman@cendio.se>2016-11-08 16:44:46 +0100
commit05338bccb76e9019f51d1528631c3eecd36026ae (patch)
tree615a0ce8467fbc62b584e3d10d28e845da025428 /common
parent76166012098efd3285d90f59c033c232ae146962 (diff)
downloadtigervnc-05338bccb76e9019f51d1528631c3eecd36026ae.tar.gz
tigervnc-05338bccb76e9019f51d1528631c3eecd36026ae.zip
Log statistics from ComparingUpdateTracker
Diffstat (limited to 'common')
-rw-r--r--common/rfb/ComparingUpdateTracker.cxx29
-rw-r--r--common/rfb/ComparingUpdateTracker.h5
-rw-r--r--common/rfb/VNCServerST.cxx9
3 files changed, 42 insertions, 1 deletions
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 <vector>
#include <rdr/types.h>
#include <rfb/Exception.h>
+#include <rfb/LogWriter.h>
#include <rfb/ComparingUpdateTracker.h>
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;