Mir
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 rendered_frame(SubCompositorId id) override;
48  void finished_frame(SubCompositorId id) override;
49  void started() override;
50  void stopped() override;
51  void scheduled() override;
52 
53 private:
54  std::shared_ptr<mir::logging::Logger> const logger;
55  std::shared_ptr<time::Clock> const clock;
56 
57  typedef time::Timestamp TimePoint;
58  TimePoint now() const;
59 
60  struct Instance
61  {
62  TimePoint start_of_frame;
63  TimePoint end_of_frame;
64  TimePoint total_time_sum;
65  TimePoint render_time_sum;
66  TimePoint latency_sum;
67  long nframes = 0;
68  long nbypassed = 0;
69  bool bypassed = true;
70  bool prev_bypassed = false;
71 
72  TimePoint last_reported_total_time_sum;
73  TimePoint last_reported_render_time_sum;
74  TimePoint last_reported_latency_sum;
75  long last_reported_nframes = 0;
76  long last_reported_bypassed = 0;
77 
78  void log(mir::logging::Logger& logger, SubCompositorId id);
79  };
80 
81  std::mutex mutex; // Protects the following...
82  std::unordered_map<SubCompositorId, Instance> instance;
83  TimePoint last_scheduled;
84  TimePoint last_report;
85 };
86 
87 } // namespace logging
88 } // namespace report
89 } // namespace mir
90 
91 #endif // MIR_REPORT_LOGGING_COMPOSITOR_REPORT_H_
All things Mir.
Definition: buffer_stream.h:37
void rendered_frame(SubCompositorId id) override
void log(logging::Severity sev, char const *component, char const *fmt,...)
Definition: log.cpp:39
const void * SubCompositorId
Definition: compositor_report.h:30
Definition: dimensions.h:35
void began_frame(SubCompositorId id) override
Definition: compositor_report.h:40
std::chrono::steady_clock::time_point Timestamp
Definition: types.h:29
Definition: logger.h:41
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
unsigned int height
Definition: black_arrow.c:5
void finished_frame(SubCompositorId id) override

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Mar 24 16:15:19 UTC 2015