Merge lp:~schwann/gallery-app/gallery-startup-log into lp:gallery-app

Proposed by Günter Schwann
Status: Merged
Approved by: Renato Araujo Oliveira Filho
Approved revision: 750
Merged at revision: 753
Proposed branch: lp:~schwann/gallery-app/gallery-startup-log
Merge into: lp:gallery-app
Diff against target: 185 lines (+49/-34)
4 files modified
src/gallery-application.cpp (+31/-23)
src/gallery-application.h (+9/-10)
src/gallery-manager.cpp (+8/-1)
src/main.cpp (+1/-0)
To merge this branch: bzr merge lp:~schwann/gallery-app/gallery-startup-log
Reviewer Review Type Date Requested Status
Renato Araujo Oliveira Filho (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+171278@code.launchpad.net

Commit message

Better and more startup feedback

Description of the change

Better and more startup feedback

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

179 + GalleryApplication::startStartupTimer();

Should you create the timer only if this was requested in the command line argument?

Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

79 + if (m_cmdLineParser->startupTimer()) {
80 + qDebug() << "MainView loaded" << m_timer->elapsed() << "ms";
81 + qDebug() << "Startup took" << m_timer->elapsed() << "ms";
82 + }

Should you destroy the m_timer here??

Revision history for this message
Günter Schwann (schwann) wrote :

> 179 + GalleryApplication::startStartupTimer();
>
> Should you create the timer only if this was requested in the command line
> argument?

That would be to late. As quite a lot of code would be executed before, and therefore a lot (more) of time would not be included.

> Should you destroy the m_timer here??

That I can do.

750. By Günter Schwann

Delete startup timer after startup is completed

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/gallery-application.cpp'
2--- src/gallery-application.cpp 2013-06-24 11:09:38 +0000
3+++ src/gallery-application.cpp 2013-06-25 13:51:31 +0000
4@@ -52,6 +52,8 @@
5 #include "resource.h"
6 #include "sharefile.h"
7
8+QElapsedTimer* GalleryApplication::m_timer = 0;
9+
10 /*!
11 * \brief GalleryApplication::GalleryApplication
12 * \param argc
13@@ -65,7 +67,6 @@
14 if (m_bguSize <= 0)
15 m_bguSize = 8;
16
17- m_timer.start();
18 m_formFactors.insert("desktop", QSize(120, 80)); // In BGU.
19 m_formFactors.insert("tablet", QSize(160, 100));
20 m_formFactors.insert("phone", QSize(71, 40));
21@@ -80,6 +81,9 @@
22
23 GalleryManager::instance(m_cmdLineParser->picturesDir(), &m_view,
24 m_cmdLineParser->logImageLoading());
25+
26+ if (m_cmdLineParser->startupTimer())
27+ qDebug() << "Construct GalleryApplication" << m_timer->elapsed() << "ms";
28 }
29
30 /*!
31@@ -99,7 +103,7 @@
32 createView();
33
34 // Delay init_collections() so the main loop is running before it kicks off.
35- QTimer::singleShot(0, this, SLOT(startInitCollections()));
36+ QTimer::singleShot(0, this, SLOT(initCollections()));
37
38 return QApplication::exec();
39 }
40@@ -180,6 +184,9 @@
41 m_view.showFullScreen();
42 else
43 m_view.show();
44+
45+ if (m_cmdLineParser->startupTimer())
46+ qDebug() << "GalleryApplication view created" << m_timer->elapsed() << "ms";
47 }
48
49 /*!
50@@ -188,26 +195,27 @@
51 void GalleryApplication::initCollections()
52 {
53 GalleryManager::instance()->postInit();
54+ if (m_cmdLineParser->startupTimer())
55+ qDebug() << "GalleryManager initialized" << m_timer->elapsed() << "ms";
56
57 emit mediaLoaded();
58-
59- if (m_cmdLineParser->startupTimer())
60- qDebug() << "Startup took" << m_timer.elapsed() << "milliseconds";
61-}
62-
63-/*!
64- * \brief GalleryApplication::startInitCollections
65- */
66-void GalleryApplication::startInitCollections()
67-{
68- initCollections();
69-}
70-
71-/*!
72- * \brief GalleryApplication::instance
73- * \return
74- */
75-GalleryApplication* GalleryApplication::instance()
76-{
77- return static_cast<GalleryApplication*>(qApp);
78-}
79+ if (m_cmdLineParser->startupTimer()) {
80+ qDebug() << "MainView loaded" << m_timer->elapsed() << "ms";
81+ qDebug() << "Startup took" << m_timer->elapsed() << "ms";
82+ }
83+
84+ delete m_timer;
85+ m_timer = 0;
86+}
87+
88+/*!
89+ * \brief GalleryApplication::startStartupTimer
90+ */
91+void GalleryApplication::startStartupTimer()
92+{
93+ if (!m_timer)
94+ m_timer = new QElapsedTimer();
95+
96+ m_timer->restart();
97+}
98+
99
100=== modified file 'src/gallery-application.h'
101--- src/gallery-application.h 2013-06-24 11:09:38 +0000
102+++ src/gallery-application.h 2013-06-25 13:51:31 +0000
103@@ -41,27 +41,26 @@
104
105 int exec();
106
107- static GalleryApplication* instance();
108-
109 Q_INVOKABLE bool runCommand(const QString &cmd, const QString &arg);
110
111+ static void startStartupTimer();
112+
113+signals:
114+ void mediaLoaded();
115+
116+private slots:
117+ void initCollections();
118+
119 private:
120 void registerQML();
121 void createView();
122- void initCollections();
123
124 QHash<QString, QSize> m_formFactors;
125 int m_bguSize;
126 QQuickView m_view;
127- QElapsedTimer m_timer;
128+ static QElapsedTimer *m_timer;
129
130 CommandLineParser* m_cmdLineParser;
131-
132-private slots:
133- void startInitCollections();
134-
135-signals:
136- void mediaLoaded();
137 };
138
139 #endif // GALLERYAPPLICATION_H
140
141=== modified file 'src/gallery-manager.cpp'
142--- src/gallery-manager.cpp 2013-06-14 13:27:05 +0000
143+++ src/gallery-manager.cpp 2013-06-25 13:51:31 +0000
144@@ -44,6 +44,8 @@
145 // util
146 #include "resource.h"
147
148+#include <QElapsedTimer>
149+
150 #include <exiv2/exiv2.hpp>
151
152 GalleryManager* GalleryManager::m_galleryManager = NULL;
153@@ -101,6 +103,8 @@
154
155 if (!collectionsInitialised)
156 {
157+ QElapsedTimer t;
158+ t.start();
159 qDebug() << "Opening" << m_resource->mediaDirectories() << "...";
160
161 Exiv2::LogMsg::setLevel(Exiv2::LogMsg::mute);
162@@ -125,7 +129,10 @@
163 QObject::connect(m_monitor, SIGNAL(mediaItemAdded(QFileInfo)), this,
164 SLOT(onMediaItemAdded(QFileInfo)));
165
166- qDebug() << "Opened" << m_resource->mediaDirectories();
167+ qDebug() << "Opened" << m_resource->mediaDirectories() << "with "
168+ << m_mediaCollection->count() << "media files in"
169+ << t.elapsed() << "ms - "
170+ << (qreal)t.elapsed() / (qreal)m_mediaCollection->count() << " ms per media";
171 }
172 }
173
174
175=== modified file 'src/main.cpp'
176--- src/main.cpp 2013-02-25 10:16:29 +0000
177+++ src/main.cpp 2013-06-25 13:51:31 +0000
178@@ -23,6 +23,7 @@
179
180 int main(int argc, char *argv[])
181 {
182+ GalleryApplication::startStartupTimer();
183 GalleryApplication app(argc, argv);
184 return app.exec();
185 }

Subscribers

People subscribed via source and target branches