Changeset View
Changeset View
Standalone View
Standalone View
perf.cpp
- This file was copied from platformsupport/scenes/opengl/swap_profiler.h.
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org> | 5 | Copyright 2019 Roman Gilg <subdiff@gmail.com> | ||
6 | Copyright (C) 2009, 2010, 2011 Martin Gräßlin <mgraesslin@kde.org> | | |||
7 | 6 | | |||
8 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or | ||
11 | (at your option) any later version. | 10 | (at your option) any later version. | ||
12 | 11 | | |||
13 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
17 | 16 | | |||
18 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | *********************************************************************/ | 19 | *********************************************************************/ | ||
21 | #ifndef KWIN_SCENE_OPENGL_SWAP_PROFILER_H | 20 | #include "perf.h" | ||
22 | #define KWIN_SCENE_OPENGL_SWAP_PROFILER_H | | |||
23 | 21 | | |||
24 | #include <QElapsedTimer> | 22 | #include <config-kwin.h> | ||
25 | #include <kwin_export.h> | 23 | | ||
24 | #ifdef KWIN_BUILD_PERF | ||||
25 | #include "helpers/perf/ftrace_marker.h" | ||||
26 | #endif | ||||
26 | 27 | | |||
27 | namespace KWin | 28 | namespace KWin | ||
28 | { | 29 | { | ||
30 | namespace Perf | ||||
31 | { | ||||
29 | 32 | | |||
30 | /** | 33 | #ifdef KWIN_BUILD_PERF | ||
31 | * @short Profiler to detect whether we have triple buffering | 34 | void PerfInterface::ftrace(const QString &message) | ||
32 | * The strategy is to start setBlocksForRetrace(false) but assume blocking and have the system prove that assumption wrong | 35 | { | ||
33 | */ | 36 | FtraceMarker::self()->print(message); | ||
34 | class KWIN_EXPORT SwapProfiler | | |||
35 | { | | |||
36 | public: | | |||
37 | SwapProfiler(); | | |||
38 | void init(); | | |||
39 | void begin(); | | |||
40 | /** | | |||
41 | * @return char being 'd' for double, 't' for triple (or more - but non-blocking) buffering and | | |||
42 | * 0 (NOT '0') otherwise, so you can act on "if (char result = SwapProfiler::end()) { fooBar(); } | | |||
43 | */ | | |||
44 | char end(); | | |||
45 | private: | | |||
46 | QElapsedTimer m_timer; | | |||
47 | qint64 m_time; | | |||
48 | int m_counter; | | |||
49 | }; | | |||
50 | | ||||
51 | } | 37 | } | ||
38 | void PerfInterface::ftrace(ulong ctx, const QString &message) | ||||
39 | { | ||||
40 | FtraceMarker::self()->print(ctx, message); | ||||
41 | } | ||||
42 | void PerfInterface::ftrace(const QString &message, ulong ctx) | ||||
43 | { | ||||
44 | FtraceMarker::self()->print(message, ctx); | ||||
45 | } | ||||
46 | | ||||
47 | #else | ||||
52 | 48 | | |||
49 | void PerfInterface::ftrace(const QString &message) | ||||
50 | { | ||||
51 | Q_UNUSED(message) | ||||
52 | } | ||||
53 | void PerfInterface::ftrace(ulong ctx, const QString &message) | ||||
54 | { | ||||
55 | Q_UNUSED(message) | ||||
56 | Q_UNUSED(ctx) | ||||
57 | } | ||||
58 | void PerfInterface::ftrace(const QString &message, ulong ctx) | ||||
59 | { | ||||
60 | Q_UNUSED(message) | ||||
61 | Q_UNUSED(ctx) | ||||
62 | } | ||||
53 | #endif | 63 | #endif | ||
64 | | ||||
65 | } | ||||
66 | } |