Преглед изворни кода

Log statistics from ComparingUpdateTracker

tags/v1.7.90
Pierre Ossman пре 7 година
родитељ
комит
05338bccb7

+ 28
- 1
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;
}

+ 5
- 0
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;
};

}

+ 9
- 0
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;

Loading…
Откажи
Сачувај