refactor: DebugCount (#6753)
Reviewed-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com> Reviewed-by: Nerixyz <nerixdev@outlook.de>
This commit is contained in:
+17
-24
@@ -36,7 +36,7 @@ namespace chatterino::detail {
|
||||
|
||||
Frames::Frames()
|
||||
{
|
||||
DebugCount::increase("images");
|
||||
DebugCount::increase(DebugObject::Image);
|
||||
}
|
||||
|
||||
Frames::Frames(QList<Frame> &&frames)
|
||||
@@ -51,15 +51,15 @@ Frames::Frames(QList<Frame> &&frames)
|
||||
return;
|
||||
}
|
||||
|
||||
DebugCount::increase("images");
|
||||
DebugCount::increase(DebugObject::Image);
|
||||
if (!this->empty())
|
||||
{
|
||||
DebugCount::increase("loaded images");
|
||||
DebugCount::increase(DebugObject::LoadedImage);
|
||||
}
|
||||
|
||||
if (this->animated())
|
||||
{
|
||||
DebugCount::increase("animated images");
|
||||
DebugCount::increase(DebugObject::AnimatedImage);
|
||||
|
||||
this->gifTimerConnection_ =
|
||||
app->getEmotes()->getGIFTimer()->signal.connect([this] {
|
||||
@@ -85,25 +85,25 @@ Frames::Frames(QList<Frame> &&frames)
|
||||
this->processOffset();
|
||||
}
|
||||
|
||||
DebugCount::increase("image bytes", this->memoryUsage());
|
||||
DebugCount::increase("image bytes (ever loaded)", this->memoryUsage());
|
||||
DebugCount::increase(DebugObject::BytesImageCurrent, this->memoryUsage());
|
||||
DebugCount::increase(DebugObject::BytesImageLoaded, this->memoryUsage());
|
||||
}
|
||||
|
||||
Frames::~Frames()
|
||||
{
|
||||
assertInGuiThread();
|
||||
DebugCount::decrease("images");
|
||||
DebugCount::decrease(DebugObject::Image);
|
||||
if (!this->empty())
|
||||
{
|
||||
DebugCount::decrease("loaded images");
|
||||
DebugCount::decrease(DebugObject::LoadedImage);
|
||||
}
|
||||
|
||||
if (this->animated())
|
||||
{
|
||||
DebugCount::decrease("animated images");
|
||||
DebugCount::decrease(DebugObject::AnimatedImage);
|
||||
}
|
||||
DebugCount::decrease("image bytes", this->memoryUsage());
|
||||
DebugCount::increase("image bytes (ever unloaded)", this->memoryUsage());
|
||||
DebugCount::decrease(DebugObject::BytesImageCurrent, this->memoryUsage());
|
||||
DebugCount::increase(DebugObject::BytesImageUnloaded, this->memoryUsage());
|
||||
|
||||
this->gifTimerConnection_.disconnect();
|
||||
}
|
||||
@@ -156,10 +156,10 @@ void Frames::clear()
|
||||
assertInGuiThread();
|
||||
if (!this->empty())
|
||||
{
|
||||
DebugCount::decrease("loaded images");
|
||||
DebugCount::decrease(DebugObject::LoadedImage);
|
||||
}
|
||||
DebugCount::decrease("image bytes", this->memoryUsage());
|
||||
DebugCount::increase("image bytes (ever unloaded)", this->memoryUsage());
|
||||
DebugCount::decrease(DebugObject::BytesImageCurrent, this->memoryUsage());
|
||||
DebugCount::increase(DebugObject::BytesImageUnloaded, this->memoryUsage());
|
||||
|
||||
this->items_.clear();
|
||||
this->index_ = 0;
|
||||
@@ -608,13 +608,6 @@ ImageExpirationPool::ImageExpirationPool()
|
||||
this->freeTimer_->start(
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
IMAGE_POOL_CLEANUP_INTERVAL));
|
||||
|
||||
// configure all debug counts used by images
|
||||
DebugCount::configure("image bytes", DebugCount::Flag::DataSize);
|
||||
DebugCount::configure("image bytes (ever loaded)",
|
||||
DebugCount::Flag::DataSize);
|
||||
DebugCount::configure("image bytes (ever unloaded)",
|
||||
DebugCount::Flag::DataSize);
|
||||
}
|
||||
|
||||
ImageExpirationPool &ImageExpirationPool::instance()
|
||||
@@ -695,9 +688,9 @@ void ImageExpirationPool::freeOld()
|
||||
qCDebug(chatterinoImage) << "freed frame data for" << numExpired << "/"
|
||||
<< eligible << "eligible images";
|
||||
# endif
|
||||
DebugCount::set("last image gc: expired", numExpired);
|
||||
DebugCount::set("last image gc: eligible", eligible);
|
||||
DebugCount::set("last image gc: left after gc", this->allImages_.size());
|
||||
DebugCount::set(DebugObject::LastImageGcExpired, numExpired);
|
||||
DebugCount::set(DebugObject::LastImageGcEligible, eligible);
|
||||
DebugCount::set(DebugObject::LastImageGcLeft, this->allImages_.size());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user