Log statistics from ComparingUpdateTracker
diff --git a/common/rfb/ComparingUpdateTracker.cxx b/common/rfb/ComparingUpdateTracker.cxx
index 1d27f3c..237adc4 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 @@
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 @@
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 fccc222..e62f2b2 100644
--- a/common/rfb/ComparingUpdateTracker.h
+++ b/common/rfb/ComparingUpdateTracker.h
@@ -40,12 +40,17 @@
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 d501085..e15cd70 100644
--- a/common/rfb/VNCServerST.cxx
+++ b/common/rfb/VNCServerST.cxx
@@ -110,6 +110,8 @@
desktop->stop();
}
+ if (comparer)
+ comparer->logStats();
delete comparer;
}
@@ -155,6 +157,10 @@
desktopStarted = false;
desktop->stop();
}
+
+ if (comparer)
+ comparer->logStats();
+
return;
}
}
@@ -292,6 +298,9 @@
void VNCServerST::setPixelBuffer(PixelBuffer* pb_, const ScreenSet& layout)
{
+ if (comparer)
+ comparer->logStats();
+
pb = pb_;
delete comparer;
comparer = 0;