93e0265e4e
Once in a while, we receive complaints from other fellow KDE developers about the file organization of kwin. This change addresses some of those complaints by moving all of source code in a separate directory, src/, thus making the project structure more traditional. Things such as tests are kept in their own toplevel directories. This change may wreak havoc on merge requests that add new files to kwin, but if a patch modifies an already existing file, git should be smart enough to figure out that the file has been relocated. We may potentially split the src/ directory further to make navigating the source code easier, but hopefully this is good enough already.
56 lines
1.2 KiB
C++
56 lines
1.2 KiB
C++
/*
|
|
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#include "renderjournal.h"
|
|
|
|
namespace KWin
|
|
{
|
|
|
|
RenderJournal::RenderJournal()
|
|
{
|
|
}
|
|
|
|
void RenderJournal::beginFrame()
|
|
{
|
|
m_timer.start();
|
|
}
|
|
|
|
void RenderJournal::endFrame()
|
|
{
|
|
std::chrono::nanoseconds duration(m_timer.nsecsElapsed());
|
|
if (m_log.count() >= m_size) {
|
|
m_log.dequeue();
|
|
}
|
|
m_log.enqueue(duration);
|
|
}
|
|
|
|
std::chrono::nanoseconds RenderJournal::minimum() const
|
|
{
|
|
auto it = std::min_element(m_log.constBegin(), m_log.constEnd());
|
|
return it != m_log.constEnd() ? (*it) : std::chrono::nanoseconds::zero();
|
|
}
|
|
|
|
std::chrono::nanoseconds RenderJournal::maximum() const
|
|
{
|
|
auto it = std::max_element(m_log.constBegin(), m_log.constEnd());
|
|
return it != m_log.constEnd() ? (*it) : std::chrono::nanoseconds::zero();
|
|
}
|
|
|
|
std::chrono::nanoseconds RenderJournal::average() const
|
|
{
|
|
if (m_log.isEmpty()) {
|
|
return std::chrono::nanoseconds::zero();
|
|
}
|
|
|
|
std::chrono::nanoseconds result = std::chrono::nanoseconds::zero();
|
|
for (const std::chrono::nanoseconds &entry : m_log) {
|
|
result += entry;
|
|
}
|
|
|
|
return result / m_log.count();
|
|
}
|
|
|
|
} // namespace KWin
|