1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 00:17:45 +00:00

Profiler: Cache the timeline histograms instead of recomputing on paint

There was an aggressive amount of work happening on every paint. :^)
This commit is contained in:
Andreas Kling 2021-06-27 12:03:12 +02:00
parent f4090d46de
commit dff3439ad0
2 changed files with 60 additions and 35 deletions

View file

@ -1,11 +1,12 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "Histogram.h"
#include <LibGUI/Frame.h>
namespace Profiler {
@ -26,11 +27,26 @@ private:
virtual void event(Core::Event&) override;
virtual void paint_event(GUI::PaintEvent&) override;
struct HistogramInputs {
bool operator==(HistogramInputs const&) const = default;
u64 start { 0 };
u64 end { 0 };
size_t columns { 0 };
};
void recompute_histograms_if_needed(HistogramInputs const&);
explicit TimelineTrack(TimelineView const&, Profile const&, Process const&);
TimelineView const& m_view;
Profile const& m_profile;
Process const& m_process;
HistogramInputs m_cached_histogram_inputs;
Optional<Histogram<u64>> m_kernel_histogram;
Optional<Histogram<u64>> m_user_histogram;
decltype(m_kernel_histogram->at(0)) m_max_value { 0 };
};
}