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
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/Aliases.hpp"
|
||||
#include "util/DebugCount.hpp"
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <pajlada/signals/signal.hpp>
|
||||
|
||||
@@ -25,12 +25,12 @@ using namespace literals;
|
||||
Message::Message()
|
||||
: parseTime(QTime::currentTime())
|
||||
{
|
||||
DebugCount::increase("messages");
|
||||
DebugCount::increase(DebugObject::Message);
|
||||
}
|
||||
|
||||
Message::~Message()
|
||||
{
|
||||
DebugCount::decrease("messages");
|
||||
DebugCount::decrease(DebugObject::Message);
|
||||
}
|
||||
|
||||
ScrollbarHighlight Message::getScrollBarHighlight() const
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "messages/MessageFlag.hpp"
|
||||
#include "providers/twitch/ChannelPointReward.hpp"
|
||||
#include "util/DebugCount.hpp"
|
||||
#include "util/QStringHash.hpp"
|
||||
|
||||
#include <QColor>
|
||||
|
||||
@@ -55,12 +55,12 @@ QSizeF getBoundingBoxSize(const std::vector<ImagePtr> &images)
|
||||
MessageElement::MessageElement(MessageElementFlags flags)
|
||||
: flags_(flags)
|
||||
{
|
||||
DebugCount::increase("message elements");
|
||||
DebugCount::increase(DebugObject::MessageElement);
|
||||
}
|
||||
|
||||
MessageElement::~MessageElement()
|
||||
{
|
||||
DebugCount::decrease("message elements");
|
||||
DebugCount::decrease(DebugObject::MessageElement);
|
||||
}
|
||||
|
||||
MessageElement *MessageElement::setLink(const Link &link)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "messages/MessageColor.hpp"
|
||||
#include "providers/links/LinkInfo.hpp"
|
||||
#include "singletons/Fonts.hpp"
|
||||
#include "util/DebugCount.hpp"
|
||||
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include <pajlada/signals/signalholder.hpp>
|
||||
|
||||
@@ -23,12 +23,12 @@ MessageThread::MessageThread(std::shared_ptr<const Message> rootMessage)
|
||||
: rootMessageId_(rootMessage->id)
|
||||
, rootMessage_(std::move(rootMessage))
|
||||
{
|
||||
DebugCount::increase("message threads");
|
||||
DebugCount::increase(DebugObject::MessageThread);
|
||||
}
|
||||
|
||||
MessageThread::~MessageThread()
|
||||
{
|
||||
DebugCount::decrease("message threads");
|
||||
DebugCount::decrease(DebugObject::MessageThread);
|
||||
}
|
||||
|
||||
void MessageThread::addToThread(const std::shared_ptr<const Message> &message)
|
||||
|
||||
@@ -41,12 +41,12 @@ QColor blendColors(const QColor &base, const QColor &apply)
|
||||
MessageLayout::MessageLayout(MessagePtr message)
|
||||
: message_(std::move(message))
|
||||
{
|
||||
DebugCount::increase("message layout");
|
||||
DebugCount::increase(DebugObject::MessageLayout);
|
||||
}
|
||||
|
||||
MessageLayout::~MessageLayout()
|
||||
{
|
||||
DebugCount::decrease("message layout");
|
||||
DebugCount::decrease(DebugObject::MessageLayout);
|
||||
}
|
||||
|
||||
const Message *MessageLayout::getMessage()
|
||||
@@ -359,7 +359,7 @@ QPixmap *MessageLayout::ensureBuffer(QPainter &painter, qreal width, bool clear)
|
||||
}
|
||||
|
||||
this->bufferValid_ = false;
|
||||
DebugCount::increase("message drawing buffers");
|
||||
DebugCount::increase(DebugObject::MessageDrawingBuffer);
|
||||
return this->buffer_.get();
|
||||
}
|
||||
|
||||
@@ -487,7 +487,7 @@ void MessageLayout::deleteBuffer()
|
||||
{
|
||||
if (this->buffer_ != nullptr)
|
||||
{
|
||||
DebugCount::decrease("message drawing buffers");
|
||||
DebugCount::decrease(DebugObject::MessageDrawingBuffer);
|
||||
|
||||
this->buffer_ = nullptr;
|
||||
}
|
||||
|
||||
@@ -40,12 +40,12 @@ MessageLayoutElement::MessageLayoutElement(MessageElement &creator, QSizeF size)
|
||||
: rect_(QPointF{}, size)
|
||||
, creator_(creator)
|
||||
{
|
||||
DebugCount::increase("message layout elements");
|
||||
DebugCount::increase(DebugObject::MessageLayoutElement);
|
||||
}
|
||||
|
||||
MessageLayoutElement::~MessageLayoutElement()
|
||||
{
|
||||
DebugCount::decrease("message layout elements");
|
||||
DebugCount::decrease(DebugObject::MessageLayoutElement);
|
||||
}
|
||||
|
||||
MessageElement &MessageLayoutElement::getCreator() const
|
||||
|
||||
Reference in New Issue
Block a user