Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
compositor_report.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
17  */
18 
19 #ifndef MIR_REPORT_LOGGING_COMPOSITOR_REPORT_H_
20 #define MIR_REPORT_LOGGING_COMPOSITOR_REPORT_H_
21 
23 #include "mir/time/clock.h"
24 #include <memory>
25 #include <mutex>
26 #include <unordered_map>
27 #include <chrono>
28 
29 namespace mir
30 {
31 namespace logging
32 {
33 class Logger;
34 }
35 namespace report
36 {
37 namespace logging
38 {
39 
41 {
42 public:
43  CompositorReport(std::shared_ptr<mir::logging::Logger> const& logger,
44  std::shared_ptr<time::Clock> const& clock);
45  void added_display(int width, int height, int x, int y, SubCompositorId id) override;
46  void began_frame(SubCompositorId id) override;
47  void finished_frame(bool bypassed, SubCompositorId id) override;
48  void started() override;
49  void stopped() override;
50  void scheduled() override;
51 
52 private:
53  std::shared_ptr<mir::logging::Logger> const logger;
54  std::shared_ptr<time::Clock> const clock;
55 
56  typedef time::Timestamp TimePoint;
57  TimePoint now() const;
58 
59  struct Instance
60  {
61  TimePoint start_of_frame;
62  TimePoint end_of_frame;
63  TimePoint total_time_sum;
64  TimePoint frame_time_sum;
65  TimePoint latency_sum;
66  long nframes = 0;
67  long nbypassed = 0;
68  bool prev_bypassed = false;
69 
70  TimePoint last_reported_total_time_sum;
71  TimePoint last_reported_frame_time_sum;
72  TimePoint last_reported_latency_sum;
73  long last_reported_nframes = 0;
74  long last_reported_bypassed = 0;
75 
76  void log(mir::logging::Logger& logger, SubCompositorId id);
77  };
78 
79  std::mutex mutex; // Protects the following...
80  std::unordered_map<SubCompositorId, Instance> instance;
81  TimePoint last_scheduled;
82  TimePoint last_report;
83 };
84 
85 } // namespace logging
86 } // namespace report
87 } // namespace mir
88 
89 #endif // MIR_REPORT_LOGGING_COMPOSITOR_REPORT_H_
All things Mir.
Definition: aging_buffer.h:24
std::chrono::high_resolution_clock::time_point Timestamp
Definition: clock.h:29
const void * SubCompositorId
Definition: compositor_report.h:30
void finished_frame(bool bypassed, SubCompositorId id) override
Definition: compositor_report.cpp:122
Definition: dimensions.h:35
void began_frame(SubCompositorId id) override
Definition: compositor_report.cpp:54
Definition: compositor_report.h:40
void scheduled() override
Definition: compositor_report.cpp:171
Definition: logger.h:30
unsigned int width
Definition: black_arrow.c:4
Definition: dimensions.h:35
Definition: compositor_report.h:27
void added_display(int width, int height, int x, int y, SubCompositorId id) override
Definition: compositor_report.cpp:46
void stopped() override
Definition: compositor_report.cpp:163
unsigned int height
Definition: black_arrow.c:5
void started() override
Definition: compositor_report.cpp:158

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Oct 10 14:07:14 UTC 2014