Merge lp:~aacid/ubuntu-ui-toolkit/lttng_frame_render_times into lp:ubuntu-ui-toolkit/staging

Proposed by Albert Astals Cid
Status: Rejected
Rejected by: Albert Astals Cid
Proposed branch: lp:~aacid/ubuntu-ui-toolkit/lttng_frame_render_times
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 704 lines (+419/-73)
15 files modified
components.api (+8/-3)
debian/qml-module-ubuntu-performancemetrics.install (+2/-0)
src/Ubuntu/PerformanceMetrics/PerformanceMetrics.pro (+4/-0)
src/Ubuntu/PerformanceMetrics/PerformanceOverlay.qml (+23/-3)
src/Ubuntu/PerformanceMetrics/lttng/lttng.pro (+7/-0)
src/Ubuntu/PerformanceMetrics/lttng/tracepoints.c (+21/-0)
src/Ubuntu/PerformanceMetrics/lttng/upmrenderingtimes_tp.h (+39/-0)
src/Ubuntu/PerformanceMetrics/plugin/plugin.pri (+6/-0)
src/Ubuntu/PerformanceMetrics/plugin/upmplugin.cpp (+9/-2)
src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimes.cpp (+4/-47)
src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimes.h (+1/-18)
src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimesgraphmodel.cpp (+88/-0)
src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimesgraphmodel.h (+65/-0)
src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimeslttng.cpp (+87/-0)
src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimeslttng.h (+55/-0)
To merge this branch: bzr merge lp:~aacid/ubuntu-ui-toolkit/lttng_frame_render_times
Reviewer Review Type Date Requested Status
Ubuntu SDK team Pending
Review via email: mp+292357@code.launchpad.net

Commit message

Log frame rendering times to lttng

To post a comment you must log in.
1943. By Albert Astals Cid

eof

1944. By Albert Astals Cid

Fix destructors

1945. By Albert Astals Cid

year

1946. By Albert Astals Cid

install the debian pkg

1947. By Albert Astals Cid

updated components.api

1948. By Albert Astals Cid

install this too

Unmerged revisions

1948. By Albert Astals Cid

install this too

1947. By Albert Astals Cid

updated components.api

1946. By Albert Astals Cid

install the debian pkg

1945. By Albert Astals Cid

year

1944. By Albert Astals Cid

Fix destructors

1943. By Albert Astals Cid

eof

1942. By Albert Astals Cid

Merge

1941. By Albert Astals Cid

Separate lttng and graph logging of frame times

1940. By Albert Astals Cid

Very crude first attempt at lttng logging frame render times

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components.api'
2--- components.api 2016-04-05 05:56:32 +0000
3+++ components.api 2016-04-20 13:04:14 +0000
4@@ -1052,11 +1052,16 @@
5 property Component defaultContent
6 property bool releaseToRefresh
7 Ubuntu.PerformanceMetrics.RenderingTimes 1.0 0.1 UPMRenderingTimes: Item
8- readonly property UPMGraphModel graphModel
9 signal frameRendered(qlonglong renderTime)
10- property int period
11- property int samples
12+ signal frameRenderedInternal(qlonglong renderTime)
13 property RenderTimer.TimerType timerType
14+Ubuntu.PerformanceMetrics.RenderingTimesGraphModel 1.0 0.1 UPMRenderingTimesGraphModel: QtObject
15+ readonly property UPMGraphModel graphModel
16+ property int period
17+ property int samples
18+ property RenderingTimes source
19+Ubuntu.PerformanceMetrics.RenderingTimesLTTNG 1.0 0.1 UPMRenderingTimesLTTNG: QtObject
20+ property RenderingTimes source
21 Ubuntu.Components.ScrollView 1.3: StyledItem
22 default property Item contentItem
23 readonly property Flickable flickableItem
24
25=== modified file 'debian/qml-module-ubuntu-performancemetrics.install'
26--- debian/qml-module-ubuntu-performancemetrics.install 2016-03-04 11:58:12 +0000
27+++ debian/qml-module-ubuntu-performancemetrics.install 2016-04-20 13:04:14 +0000
28@@ -1,4 +1,6 @@
29 usr/lib/*/qt5/qml/Ubuntu/PerformanceMetrics/*.qml
30 usr/lib/*/qt5/qml/Ubuntu/PerformanceMetrics/libUbuntuPerformanceMetrics.so
31+usr/lib/*/qt5/qml/Ubuntu/PerformanceMetrics/libUbuntuPerformanceMetricsLTTNG.so*
32+usr/lib/*/qt5/qml/Ubuntu/PerformanceMetrics/libUbuntuPerformanceMetricsLTTNG.prl
33 usr/lib/*/qt5/qml/Ubuntu/PerformanceMetrics/plugins.qmltypes
34 usr/lib/*/qt5/qml/Ubuntu/PerformanceMetrics/qmldir
35
36=== added file 'src/Ubuntu/PerformanceMetrics/PerformanceMetrics.pro'
37--- src/Ubuntu/PerformanceMetrics/PerformanceMetrics.pro 1970-01-01 00:00:00 +0000
38+++ src/Ubuntu/PerformanceMetrics/PerformanceMetrics.pro 2016-04-20 13:04:14 +0000
39@@ -0,0 +1,4 @@
40+TEMPLATE = subdirs
41+
42+SUBDIRS += PerformanceMetricsModule.pro \
43+ lttng
44
45=== renamed file 'src/Ubuntu/PerformanceMetrics/PerformanceMetrics.pro' => 'src/Ubuntu/PerformanceMetrics/PerformanceMetricsModule.pro'
46=== modified file 'src/Ubuntu/PerformanceMetrics/PerformanceOverlay.qml'
47--- src/Ubuntu/PerformanceMetrics/PerformanceOverlay.qml 2015-03-03 13:47:48 +0000
48+++ src/Ubuntu/PerformanceMetrics/PerformanceOverlay.qml 2016-04-20 13:04:14 +0000
49@@ -55,11 +55,11 @@
50 width: units.gu(38)
51 height: childrenRect.height
52
53- PerformanceMetrics.RenderingTimes {
54+ PerformanceMetrics.RenderingTimesGraphModel {
55 id: renderingTimes
56+ source: reneringTimesLoader.item
57 period: 2000
58 samples: renderingTimeGraph.width
59- timerType: PerformanceMetrics.RenderingTimes.Trivial
60 }
61
62 PerformanceMetrics.CpuUsage {
63@@ -137,10 +137,30 @@
64 }
65
66 Loader {
67- id: loader
68+ id: reneringTimesLoader
69+ anchors.fill: parent
70+ asynchronous: true
71+ active: graphsLoader.active || lttngLoader.active
72+ sourceComponent: PerformanceMetrics.RenderingTimes {
73+ timerType: PerformanceMetrics.RenderingTimes.Trivial
74+ }
75+ }
76+
77+ Loader {
78+ id: graphsLoader
79 anchors.fill: parent
80 active: overlay.active
81 asynchronous: true
82 sourceComponent: overlayContent
83 }
84+
85+ Loader {
86+ id: lttngLoader
87+ anchors.fill: parent
88+ active: performanceLTTNGEnabled
89+ asynchronous: true
90+ sourceComponent: PerformanceMetrics.RenderingTimesLTTNG {
91+ source: reneringTimesLoader.item
92+ }
93+ }
94 }
95
96=== added directory 'src/Ubuntu/PerformanceMetrics/lttng'
97=== added file 'src/Ubuntu/PerformanceMetrics/lttng/lttng.pro'
98--- src/Ubuntu/PerformanceMetrics/lttng/lttng.pro 1970-01-01 00:00:00 +0000
99+++ src/Ubuntu/PerformanceMetrics/lttng/lttng.pro 2016-04-20 13:04:14 +0000
100@@ -0,0 +1,7 @@
101+TEMPLATE = lib
102+TARGET = UbuntuPerformanceMetricsLTTNG
103+SOURCES = tracepoints.c
104+LIBS += -llttng-ust
105+
106+target.path = $$[QT_INSTALL_QML]/Ubuntu/PerformanceMetrics
107+INSTALLS += target
108
109=== added file 'src/Ubuntu/PerformanceMetrics/lttng/tracepoints.c'
110--- src/Ubuntu/PerformanceMetrics/lttng/tracepoints.c 1970-01-01 00:00:00 +0000
111+++ src/Ubuntu/PerformanceMetrics/lttng/tracepoints.c 2016-04-20 13:04:14 +0000
112@@ -0,0 +1,21 @@
113+/*
114+ * Copyright 2016 Canonical Ltd.
115+ *
116+ * This program is free software; you can redistribute it and/or modify
117+ * it under the terms of the GNU Lesser General Public License as published by
118+ * the Free Software Foundation; version 3.
119+ *
120+ * This program is distributed in the hope that it will be useful,
121+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
122+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
123+ * GNU Lesser General Public License for more details.
124+ *
125+ * You should have received a copy of the GNU Lesser General Public License
126+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
127+ *
128+ */
129+
130+/* The probes need to be compiled in a C file (not C++) */
131+#define TRACEPOINT_CREATE_PROBES
132+
133+#include "upmrenderingtimes_tp.h"
134
135=== added file 'src/Ubuntu/PerformanceMetrics/lttng/upmrenderingtimes_tp.h'
136--- src/Ubuntu/PerformanceMetrics/lttng/upmrenderingtimes_tp.h 1970-01-01 00:00:00 +0000
137+++ src/Ubuntu/PerformanceMetrics/lttng/upmrenderingtimes_tp.h 2016-04-20 13:04:14 +0000
138@@ -0,0 +1,39 @@
139+/*
140+ * Copyright 2016 Canonical Ltd.
141+ *
142+ * This program is free software; you can redistribute it and/or modify
143+ * it under the terms of the GNU Lesser General Public License as published by
144+ * the Free Software Foundation; version 3.
145+ *
146+ * This program is distributed in the hope that it will be useful,
147+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
148+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
149+ * GNU Lesser General Public License for more details.
150+ *
151+ * You should have received a copy of the GNU Lesser General Public License
152+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
153+ *
154+ */
155+
156+#undef TRACEPOINT_PROVIDER
157+#define TRACEPOINT_PROVIDER upm_rendering_times
158+
159+#if !defined(UPM_RENDERING_TIMES_TP_H_) || defined(TRACEPOINT_HEADER_MULTI_READ)
160+#define UPM_RENDERING_TIMES_TP_H_
161+
162+#include <lttng/tracepoint.h>
163+
164+TRACEPOINT_EVENT(upm_rendering_times, frame_render,
165+ TP_ARGS(int, anint),
166+ TP_FIELDS(
167+ ctf_integer(int, frame_render_time, anint)
168+ )
169+)
170+
171+#endif
172+
173+#undef TRACEPOINT_INCLUDE
174+#define TRACEPOINT_INCLUDE "./upmrenderingtimes_tp.h"
175+
176+/* This part must be outside ifdef protection */
177+#include <lttng/tracepoint-event.h>
178
179=== modified file 'src/Ubuntu/PerformanceMetrics/plugin/plugin.pri'
180--- src/Ubuntu/PerformanceMetrics/plugin/plugin.pri 2016-01-19 13:01:44 +0000
181+++ src/Ubuntu/PerformanceMetrics/plugin/plugin.pri 2016-04-20 13:04:14 +0000
182@@ -2,6 +2,8 @@
183 CONFIG += no_keywords
184
185 DEFINES += QT_USE_QSTRINGBUILDER
186+DEFINES += LTTNG_METRICS_INSTALL_LIB_PATH=\\\"$$[QT_INSTALL_QML]/$$TARGETPATH/libUbuntuPerformanceMetricsLTTNG.so.1.0.0\\\"
187+DEFINES += LTTNG_METRICS_BUILD_LIB_PATH=\\\"$$OUT_PWD/lttng/libUbuntuPerformanceMetricsLTTNG.so.1.0.0\\\"
188
189 # Input
190 SOURCES += \
191@@ -9,6 +11,8 @@
192 $$PWD/upmgraphmodel.cpp \
193 $$PWD/upmtexturefromimage.cpp \
194 $$PWD/upmrenderingtimes.cpp \
195+ $$PWD/upmrenderingtimesgraphmodel.cpp \
196+ $$PWD/upmrenderingtimeslttng.cpp \
197 $$PWD/upmcpuusage.cpp \
198 $$PWD/rendertimer.cpp
199
200@@ -17,6 +21,8 @@
201 $$PWD/upmgraphmodel.h \
202 $$PWD/upmtexturefromimage.h \
203 $$PWD/upmrenderingtimes.h \
204+ $$PWD/upmrenderingtimesgraphmodel.h \
205+ $$PWD/upmrenderingtimeslttng.h \
206 $$PWD/upmcpuusage.h \
207 $$PWD/rendertimer.h
208
209
210=== modified file 'src/Ubuntu/PerformanceMetrics/plugin/upmplugin.cpp'
211--- src/Ubuntu/PerformanceMetrics/plugin/upmplugin.cpp 2016-01-19 13:01:44 +0000
212+++ src/Ubuntu/PerformanceMetrics/plugin/upmplugin.cpp 2016-04-20 13:04:14 +0000
213@@ -25,10 +25,14 @@
214 #include <QtQml/QQmlEngine>
215 #include <QtQml/QQmlContext>
216 #include "upmrenderingtimes.h"
217+#include "upmrenderingtimesgraphmodel.h"
218+#include "upmrenderingtimeslttng.h"
219
220 void UbuntuPerformanceMetricsPlugin::registerTypeVersion(const char *uri, int major, int minor)
221 {
222 qmlRegisterType<UPMRenderingTimes>(uri, major, minor, "RenderingTimes");
223+ qmlRegisterType<UPMRenderingTimesGraphModel>(uri, major, minor, "RenderingTimesGraphModel");
224+ qmlRegisterType<UPMRenderingTimesLTTNG>(uri, major, minor, "RenderingTimesLTTNG");
225 qmlRegisterType<UPMCpuUsage>(uri, major, minor, "CpuUsage");
226 qmlRegisterType<UPMTextureFromImage>(uri, major, minor, "TextureFromImage");
227 qmlRegisterType<UPMGraphModel>();
228@@ -45,6 +49,9 @@
229 {
230 QQmlExtensionPlugin::initializeEngine(engine, uri);
231 QQmlContext* context = engine->rootContext();
232- QByteArray performanceOverlay = qgetenv("PERFORMANCE_OVERLAY");
233- context->setContextProperty("performanceOverlayEnabled", QVariant(!performanceOverlay.isEmpty()));
234+ const bool enablePerformanceOverlay = qEnvironmentVariableIsSet("PERFORMANCE_OVERLAY");
235+ context->setContextProperty("performanceOverlayEnabled", QVariant(enablePerformanceOverlay));
236+
237+ const bool enablePerformanceLTTNG = qEnvironmentVariableIsSet("PERFORMANCE_LTTNG");
238+ context->setContextProperty("performanceLTTNGEnabled", QVariant(enablePerformanceLTTNG));
239 }
240
241=== modified file 'src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimes.cpp'
242--- src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimes.cpp 2014-02-11 17:40:02 +0000
243+++ src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimes.cpp 2016-04-20 13:04:14 +0000
244@@ -17,56 +17,21 @@
245 */
246
247 #include "upmrenderingtimes.h"
248-#include <QtCore/qmath.h>
249
250 UPMRenderingTimes::UPMRenderingTimes(QQuickItem* parent) :
251 QQuickItem(parent),
252- m_period(1000),
253- m_graphModel(new UPMGraphModel(this)),
254 m_timerType(RenderTimer::Automatic),
255 m_needsNewTimer(true),
256 m_window(NULL),
257 m_oddFrame(false),
258 m_oddFrameRenderTime(0)
259 {
260- /* Forward samplesChanged signal from graphModel */
261- QObject::connect(m_graphModel, &UPMGraphModel::samplesChanged,
262- this, &UPMRenderingTimes::samplesChanged);
263-
264 /* Periodically append render time of the most costly frame rendered.
265 The period is period / samples */
266- QObject::connect(this, &UPMRenderingTimes::frameRendered,
267+ QObject::connect(this, &UPMRenderingTimes::frameRenderedInternal,
268 this, &UPMRenderingTimes::onFrameRendered);
269 }
270
271-int UPMRenderingTimes::period() const
272-{
273- return m_period;
274-}
275-
276-void UPMRenderingTimes::setPeriod(int period)
277-{
278- if (period != m_period) {
279- m_period = period;
280- Q_EMIT periodChanged();
281- }
282-}
283-
284-int UPMRenderingTimes::samples() const
285-{
286- return m_graphModel->samples();
287-}
288-
289-void UPMRenderingTimes::setSamples(int samples)
290-{
291- m_graphModel->setSamples(samples);
292-}
293-
294-UPMGraphModel* UPMRenderingTimes::graphModel() const
295-{
296- return m_graphModel;
297-}
298-
299 RenderTimer::TimerType UPMRenderingTimes::timerType() const
300 {
301 return m_timerType;
302@@ -148,7 +113,7 @@
303
304 void UPMRenderingTimes::onAfterRendering()
305 {
306- Q_EMIT frameRendered(m_renderingTimer.stop());
307+ Q_EMIT frameRenderedInternal(m_renderingTimer.stop());
308 }
309
310 void UPMRenderingTimes::onFrameSwapped()
311@@ -158,18 +123,10 @@
312 void UPMRenderingTimes::onFrameRendered(qint64 renderTime)
313 {
314 if (!m_oddFrame) {
315- appendRenderTime(m_oddFrameRenderTime);
316- appendRenderTime(renderTime);
317+ Q_EMIT frameRendered(m_oddFrameRenderTime);
318+ Q_EMIT frameRendered(renderTime);
319 } else {
320 m_oddFrameRenderTime = renderTime;
321 }
322 m_oddFrame = !m_oddFrame;
323 }
324-
325-
326-void UPMRenderingTimes::appendRenderTime(qint64 renderTime)
327-{
328- int renderTimeInMs = qCeil((qreal)renderTime / 1000000);
329- int width = ((qreal)samples() / m_period) * renderTimeInMs;
330- m_graphModel->appendValue(width, renderTimeInMs);
331-}
332
333=== modified file 'src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimes.h'
334--- src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimes.h 2014-02-11 17:40:02 +0000
335+++ src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimes.h 2016-04-20 13:04:14 +0000
336@@ -21,17 +21,12 @@
337
338 #include <QtQuick/QQuickItem>
339 #include <QtQuick/QQuickWindow>
340-#include <QtCore/QElapsedTimer>
341-#include "upmgraphmodel.h"
342 #include "rendertimer.h"
343
344 class UPMRenderingTimes : public QQuickItem
345 {
346 Q_OBJECT
347
348- Q_PROPERTY(int period READ period WRITE setPeriod NOTIFY periodChanged)
349- Q_PROPERTY(int samples READ samples WRITE setSamples NOTIFY samplesChanged)
350- Q_PROPERTY(UPMGraphModel* graphModel READ graphModel NOTIFY graphModelChanged)
351 Q_PROPERTY(RenderTimer::TimerType timerType READ timerType WRITE setTimerType NOTIFY timerTypeChanged)
352
353 Q_ENUMS(RenderTimer::TimerType)
354@@ -40,22 +35,15 @@
355 explicit UPMRenderingTimes(QQuickItem* parent = 0);
356
357 // getters
358- int period() const;
359- int samples() const;
360- UPMGraphModel* graphModel() const;
361 RenderTimer::TimerType timerType() const;
362
363 // setters
364- void setPeriod(int period);
365- void setSamples(int samples);
366 void setTimerType(RenderTimer::TimerType timerType);
367
368 Q_SIGNALS:
369- void periodChanged();
370- void samplesChanged();
371- void graphModelChanged();
372 void timerTypeChanged();
373 void frameRendered(qint64 renderTime);
374+ void frameRenderedInternal(qint64 renderTime);
375
376 protected:
377 void itemChange(ItemChange change, const ItemChangeData & value);
378@@ -70,11 +58,6 @@
379 void onFrameRendered(qint64 renderTime);
380
381 private:
382- void appendRenderTime(qint64 renderTime);
383-
384-private:
385- int m_period;
386- UPMGraphModel* m_graphModel;
387 RenderTimer::TimerType m_timerType;
388 bool m_needsNewTimer;
389 RenderTimer m_renderingTimer;
390
391=== added file 'src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimesgraphmodel.cpp'
392--- src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimesgraphmodel.cpp 1970-01-01 00:00:00 +0000
393+++ src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimesgraphmodel.cpp 2016-04-20 13:04:14 +0000
394@@ -0,0 +1,88 @@
395+/*
396+ * Copyright 2016 Canonical Ltd.
397+ *
398+ * This program is free software; you can redistribute it and/or modify
399+ * it under the terms of the GNU Lesser General Public License as published by
400+ * the Free Software Foundation; version 3.
401+ *
402+ * This program is distributed in the hope that it will be useful,
403+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
404+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
405+ * GNU Lesser General Public License for more details.
406+ *
407+ * You should have received a copy of the GNU Lesser General Public License
408+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
409+ *
410+ */
411+
412+#include "upmrenderingtimesgraphmodel.h"
413+#include "upmrenderingtimes.h"
414+
415+#include <QtCore/qmath.h>
416+
417+
418+UPMRenderingTimesGraphModel::UPMRenderingTimesGraphModel(QObject* parent) :
419+ QObject(parent),
420+ m_period(1000),
421+ m_graphModel(new UPMGraphModel(this)),
422+ m_source(nullptr)
423+{
424+ /* Forward samplesChanged signal from graphModel */
425+ QObject::connect(m_graphModel, &UPMGraphModel::samplesChanged,
426+ this, &UPMRenderingTimesGraphModel::samplesChanged);
427+}
428+
429+int UPMRenderingTimesGraphModel::period() const
430+{
431+ return m_period;
432+}
433+
434+void UPMRenderingTimesGraphModel::setPeriod(int period)
435+{
436+ if (period != m_period) {
437+ m_period = period;
438+ Q_EMIT periodChanged();
439+ }
440+}
441+
442+int UPMRenderingTimesGraphModel::samples() const
443+{
444+ return m_graphModel->samples();
445+}
446+
447+void UPMRenderingTimesGraphModel::setSamples(int samples)
448+{
449+ m_graphModel->setSamples(samples);
450+}
451+
452+UPMGraphModel* UPMRenderingTimesGraphModel::graphModel() const
453+{
454+ return m_graphModel;
455+}
456+
457+UPMRenderingTimes* UPMRenderingTimesGraphModel::source() const
458+{
459+ return m_source;
460+}
461+
462+void UPMRenderingTimesGraphModel::setSource(UPMRenderingTimes *source)
463+{
464+ if (source != m_source) {
465+ if (m_source) {
466+ m_source->disconnect(this);
467+ }
468+
469+ if (source) {
470+ connect(source, &UPMRenderingTimes::frameRendered,
471+ this, &UPMRenderingTimesGraphModel::onFrameRendered);
472+ }
473+ Q_EMIT sourceChanged();
474+ }
475+}
476+
477+void UPMRenderingTimesGraphModel::onFrameRendered(qint64 renderTime)
478+{
479+ const int renderTimeInMs = qCeil((qreal)renderTime / 1000000);
480+ const int width = ((qreal)samples() / m_period) * renderTimeInMs;
481+ m_graphModel->appendValue(width, renderTimeInMs);
482+}
483
484=== added file 'src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimesgraphmodel.h'
485--- src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimesgraphmodel.h 1970-01-01 00:00:00 +0000
486+++ src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimesgraphmodel.h 2016-04-20 13:04:14 +0000
487@@ -0,0 +1,65 @@
488+/*
489+ * Copyright 2016 Canonical Ltd.
490+ *
491+ * This program is free software; you can redistribute it and/or modify
492+ * it under the terms of the GNU Lesser General Public License as published by
493+ * the Free Software Foundation; version 3.
494+ *
495+ * This program is distributed in the hope that it will be useful,
496+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
497+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
498+ * GNU Lesser General Public License for more details.
499+ *
500+ * You should have received a copy of the GNU Lesser General Public License
501+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
502+ *
503+ */
504+
505+#ifndef UPM_RENDERING_TIMES_GRAPH_MODEL_H
506+#define UPM_RENDERING_TIMES_GRAPH_MODEL_H
507+
508+#include <QObject>
509+
510+#include "upmgraphmodel.h"
511+
512+class UPMRenderingTimes;
513+
514+class UPMRenderingTimesGraphModel : public QObject
515+{
516+ Q_OBJECT
517+
518+ Q_PROPERTY(int period READ period WRITE setPeriod NOTIFY periodChanged)
519+ Q_PROPERTY(int samples READ samples WRITE setSamples NOTIFY samplesChanged)
520+ Q_PROPERTY(UPMGraphModel* graphModel READ graphModel NOTIFY graphModelChanged)
521+ Q_PROPERTY(UPMRenderingTimes* source READ source WRITE setSource NOTIFY sourceChanged);
522+
523+public:
524+ explicit UPMRenderingTimesGraphModel(QObject* parent = 0);
525+
526+ // getters
527+ int period() const;
528+ int samples() const;
529+ UPMGraphModel* graphModel() const;
530+ UPMRenderingTimes* source() const;
531+
532+ // setters
533+ void setPeriod(int period);
534+ void setSamples(int samples);
535+ void setSource(UPMRenderingTimes *source);
536+
537+Q_SIGNALS:
538+ void periodChanged();
539+ void samplesChanged();
540+ void graphModelChanged();
541+ void sourceChanged();
542+
543+private Q_SLOTS:
544+ void onFrameRendered(qint64 renderTime);
545+
546+private:
547+ int m_period;
548+ UPMGraphModel* m_graphModel;
549+ UPMRenderingTimes* m_source;
550+};
551+
552+#endif
553
554=== added file 'src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimeslttng.cpp'
555--- src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimeslttng.cpp 1970-01-01 00:00:00 +0000
556+++ src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimeslttng.cpp 2016-04-20 13:04:14 +0000
557@@ -0,0 +1,87 @@
558+/*
559+ * Copyright 2016 Canonical Ltd.
560+ *
561+ * This program is free software; you can redistribute it and/or modify
562+ * it under the terms of the GNU Lesser General Public License as published by
563+ * the Free Software Foundation; version 3.
564+ *
565+ * This program is distributed in the hope that it will be useful,
566+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
567+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
568+ * GNU Lesser General Public License for more details.
569+ *
570+ * You should have received a copy of the GNU Lesser General Public License
571+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
572+ *
573+ */
574+
575+#include "upmrenderingtimeslttng.h"
576+#include "upmrenderingtimes.h"
577+
578+#include <QtCore/qmath.h>
579+
580+#include <dlfcn.h>
581+
582+#define TRACEPOINT_DEFINE
583+#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
584+#include "lttng/upmrenderingtimes_tp.h"
585+
586+UPMRenderingTimesLTTNG::UPMRenderingTimesLTTNG(QObject* parent) :
587+ QObject(parent),
588+ m_lttngLib(nullptr),
589+ m_lttngLibLoadTried(false),
590+ m_source(nullptr)
591+{
592+}
593+
594+UPMRenderingTimesLTTNG::~UPMRenderingTimesLTTNG()
595+{
596+ dlclose(m_lttngLib);
597+}
598+
599+UPMRenderingTimes* UPMRenderingTimesLTTNG::source() const
600+{
601+ return m_source;
602+}
603+
604+void UPMRenderingTimesLTTNG::setSource(UPMRenderingTimes *source)
605+{
606+ if (source != m_source) {
607+ if (m_source) {
608+ m_source->disconnect(this);
609+ }
610+
611+ if (source) {
612+ connect(source, &UPMRenderingTimes::frameRendered,
613+ this, &UPMRenderingTimesLTTNG::onFrameRendered);
614+ }
615+ Q_EMIT sourceChanged();
616+ }
617+}
618+
619+void UPMRenderingTimesLTTNG::onFrameRendered(qint64 renderTime)
620+{
621+ const int renderTimeInMs = qCeil((qreal)renderTime / 1000000);
622+
623+ if (!m_lttngLib && !m_lttngLibLoadTried) {
624+ m_lttngLibLoadTried = true;
625+
626+ m_lttngLib = dlopen(LTTNG_METRICS_INSTALL_LIB_PATH, RTLD_NOW);
627+ if (!m_lttngLib) {
628+ qWarning() << "Failed to load intsalled tracepoint provider: " << dlerror();
629+ qWarning() << "Trying with build time one";
630+
631+ m_lttngLib = dlopen(LTTNG_METRICS_BUILD_LIB_PATH, RTLD_NOW);
632+ if (!m_lttngLib) {
633+ qWarning() << "Failed to load build time tracepoint provider: " << dlerror();
634+ }
635+ }
636+
637+ if (m_lttngLib) {
638+ qDebug() << "Tracing frame rendering times to lttng";
639+ }
640+ }
641+ if (m_lttngLib) {
642+ tracepoint(upm_rendering_times, frame_render, renderTimeInMs);
643+ }
644+}
645
646=== added file 'src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimeslttng.h'
647--- src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimeslttng.h 1970-01-01 00:00:00 +0000
648+++ src/Ubuntu/PerformanceMetrics/plugin/upmrenderingtimeslttng.h 2016-04-20 13:04:14 +0000
649@@ -0,0 +1,55 @@
650+/*
651+ * Copyright 2016 Canonical Ltd.
652+ *
653+ * This program is free software; you can redistribute it and/or modify
654+ * it under the terms of the GNU Lesser General Public License as published by
655+ * the Free Software Foundation; version 3.
656+ *
657+ * This program is distributed in the hope that it will be useful,
658+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
659+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
660+ * GNU Lesser General Public License for more details.
661+ *
662+ * You should have received a copy of the GNU Lesser General Public License
663+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
664+ *
665+ */
666+
667+#ifndef UPM_RENDERING_TIMES_LTTNG_H
668+#define UPM_RENDERING_TIMES_LTTNG_H
669+
670+#include <QObject>
671+
672+#include "upmgraphmodel.h"
673+
674+class UPMRenderingTimes;
675+
676+class UPMRenderingTimesLTTNG : public QObject
677+{
678+ Q_OBJECT
679+
680+ Q_PROPERTY(UPMRenderingTimes* source READ source WRITE setSource NOTIFY sourceChanged);
681+
682+public:
683+ explicit UPMRenderingTimesLTTNG(QObject* parent = 0);
684+ ~UPMRenderingTimesLTTNG();
685+
686+ // getters
687+ UPMRenderingTimes* source() const;
688+
689+ // setters
690+ void setSource(UPMRenderingTimes *source);
691+
692+Q_SIGNALS:
693+ void sourceChanged();
694+
695+private Q_SLOTS:
696+ void onFrameRendered(qint64 renderTime);
697+
698+private:
699+ void* m_lttngLib;
700+ bool m_lttngLibLoadTried;
701+ UPMRenderingTimes* m_source;
702+};
703+
704+#endif

Subscribers

People subscribed via source and target branches