Changeset View
Changeset View
Standalone View
Standalone View
helpers/perf/ftrace_marker.h
- 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 | #pragma once | ||
22 | #define KWIN_SCENE_OPENGL_SWAP_PROFILER_H | | |||
23 | 21 | | |||
24 | #include <QElapsedTimer> | 22 | #include <kwinglobals.h> | ||
25 | #include <kwin_export.h> | 23 | | ||
24 | #include <QFile> | ||||
26 | 25 | | |||
27 | namespace KWin | 26 | namespace KWin | ||
28 | { | 27 | { | ||
28 | namespace Perf | ||||
29 | { | ||||
29 | 30 | | |||
30 | /** | 31 | /** | ||
31 | * @short Profiler to detect whether we have triple buffering | 32 | * Provides an interface to mark the Ftrace output for debugging. | ||
32 | * The strategy is to start setBlocksForRetrace(false) but assume blocking and have the system prove that assumption wrong | | |||
33 | */ | 33 | */ | ||
34 | class KWIN_EXPORT SwapProfiler | 34 | class FtraceMarker : public QObject | ||
35 | { | 35 | { | ||
36 | Q_OBJECT | ||||
36 | public: | 37 | public: | ||
37 | SwapProfiler(); | 38 | virtual ~FtraceMarker() = default; | ||
38 | void init(); | 39 | | ||
39 | void begin(); | 40 | bool setEnabled(bool enable); | ||
40 | /** | 41 | void print(const QString &message); | ||
41 | * @return char being 'd' for double, 't' for triple (or more - but non-blocking) buffering and | 42 | void print(ulong ctx, const QString &message); | ||
42 | * 0 (NOT '0') otherwise, so you can act on "if (char result = SwapProfiler::end()) { fooBar(); } | 43 | void print(const QString &message, ulong ctx); | ||
43 | */ | 44 | | ||
44 | char end(); | | |||
45 | private: | 45 | private: | ||
46 | QElapsedTimer m_timer; | 46 | bool findFile(); | ||
47 | qint64 m_time; | 47 | | ||
48 | int m_counter; | 48 | QFile *m_file = nullptr; | ||
49 | | ||||
50 | KWIN_SINGLETON(FtraceMarker) | ||||
49 | }; | 51 | }; | ||
50 | 52 | | |||
51 | } | 53 | } | ||
52 | 54 | } | |||
53 | #endif | |