mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
mobile: add timer to measure startup.
Subsurface-mobile has a long startup time; in order to isolate the problem(s) a timer is added to see where time is "lost". The collected startup times are added to the clipboard together with the other logs, allowing test users to report back. All this is only enabled when compiling with -DENABLE_STARTUP_TIMING Closes #1340 [Dirk Hohndel: collapsed multiple commits and minor white space cleanups, added missing QMutex variable] Signed-off-by: Jan Iversen <jani@apache.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
3963e44404
commit
76f61468e6
4 changed files with 77 additions and 0 deletions
|
@ -19,14 +19,50 @@
|
|||
#include <QLocale>
|
||||
#include <git2.h>
|
||||
|
||||
// Implementation of STP logging
|
||||
#include "core/ssrf.h"
|
||||
#ifdef ENABLE_STARTUP_TIMING
|
||||
#include <QElapsedTimer>
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
void log_stp(const char *ident, QString *buf)
|
||||
{
|
||||
static bool firstCall = true;
|
||||
static QElapsedTimer stpDuration;
|
||||
static QString stpText;
|
||||
static QMutex logMutex;
|
||||
|
||||
QMutexLocker l(&logMutex);
|
||||
|
||||
if (firstCall) {
|
||||
firstCall = false;
|
||||
stpDuration.start();
|
||||
}
|
||||
if (ident)
|
||||
stpText += QString("STP ") \
|
||||
.append(QString::number(stpDuration.elapsed())) \
|
||||
.append(" ms, ") \
|
||||
.append(ident) \
|
||||
.append("\n");
|
||||
if (buf) {
|
||||
*buf += "---------- startup timer ----------\n";
|
||||
*buf += stpText;
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_STARTUP_TIMING
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
LOG_STP("main starting");
|
||||
|
||||
int i;
|
||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
|
||||
|
||||
// Start application
|
||||
new QApplication(argc, argv);
|
||||
LOG_STP("main Qt started");
|
||||
|
||||
// and get comand line arguments
|
||||
QStringList arguments = QCoreApplication::arguments();
|
||||
|
@ -41,6 +77,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
git_libgit2_init();
|
||||
LOG_STP("main git loaded");
|
||||
setup_system_prefs();
|
||||
if (QLocale().measurementSystem() == QLocale::MetricSystem)
|
||||
default_prefs.units = SI_units;
|
||||
|
@ -51,8 +88,11 @@ int main(int argc, char **argv)
|
|||
fill_computer_list();
|
||||
|
||||
parse_xml_init();
|
||||
LOG_STP("main xml parsed");
|
||||
taglist_init_global();
|
||||
LOG_STP("main taglist done");
|
||||
init_ui();
|
||||
LOG_STP("main init_ui done");
|
||||
if (prefs.default_file_behavior == LOCAL_DEFAULT_FILE)
|
||||
set_filename(prefs.default_filename);
|
||||
else
|
||||
|
@ -66,6 +106,7 @@ int main(int argc, char **argv)
|
|||
|
||||
init_proxy();
|
||||
|
||||
LOG_STP("main call run_ui (continue in qmlmanager)");
|
||||
if (!quit)
|
||||
run_ui();
|
||||
exit_ui();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue