mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-25 12:13:00 +01:00
Add benchmark and doctest metrics
This commit is contained in:
parent
927973868e
commit
dcc7986ff9
@ -2,6 +2,7 @@ stages:
|
||||
- check
|
||||
- build
|
||||
- test
|
||||
- benchmark
|
||||
|
||||
check:
|
||||
stage: check
|
||||
@ -127,6 +128,24 @@ test:windows_release:
|
||||
junit: test-report-junit.xml
|
||||
|
||||
|
||||
benchmark:windows_release:
|
||||
stage: benchmark
|
||||
tags:
|
||||
- windows10
|
||||
- vs2019
|
||||
dependencies:
|
||||
- build:windows_release
|
||||
needs:
|
||||
- build:windows_release
|
||||
script:
|
||||
- ./build-x64-window-release/bin/ScreenPlay.exe --benchmark
|
||||
artifacts:
|
||||
expire_in: '4 weeks'
|
||||
when: always
|
||||
reports:
|
||||
metrics: metrics.txt
|
||||
|
||||
|
||||
build_docs:
|
||||
stage: .post
|
||||
script:
|
||||
|
7
Docs/ContinousIntegration.md
Normal file
7
Docs/ContinousIntegration.md
Normal file
@ -0,0 +1,7 @@
|
||||
### Continous Inegration
|
||||
|
||||
##### Code Checks
|
||||
|
||||
##### Benchmarks
|
||||
|
||||
##### Unit tests
|
@ -43,6 +43,9 @@ namespace ScreenPlay {
|
||||
App::App()
|
||||
: QObject(nullptr)
|
||||
{
|
||||
|
||||
m_continuousIntegrationMetricsTimer.start();
|
||||
|
||||
QGuiApplication::setWindowIcon(QIcon(":/assets/icons/app.ico"));
|
||||
QGuiApplication::setOrganizationName("ScreenPlay");
|
||||
QGuiApplication::setOrganizationDomain("screen-play.app");
|
||||
@ -120,6 +123,7 @@ App::App()
|
||||
// ScreenPlayManager first to check if another ScreenPlay Instace is running
|
||||
m_screenPlayManager = std::make_unique<ScreenPlayManager>();
|
||||
m_isAnotherScreenPlayInstanceRunning = m_screenPlayManager->isAnotherScreenPlayInstanceRunning();
|
||||
Util::appendToMetricsFile("screenplay_app_constructor", m_continuousIntegrationMetricsTimer.msecsSinceReference());
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -130,6 +134,9 @@ App::App()
|
||||
*/
|
||||
void App::init()
|
||||
{
|
||||
|
||||
Util::appendToMetricsFile("screenplay_app_init", m_continuousIntegrationMetricsTimer.msecsSinceReference());
|
||||
|
||||
using std::make_shared, std::make_unique;
|
||||
|
||||
// Util should be created as first so we redirect qDebugs etc. into the log
|
||||
@ -187,8 +194,9 @@ void App::init()
|
||||
}
|
||||
|
||||
qmlRegisterSingletonInstance("ScreenPlay", 1, 0, "ScreenPlay", this);
|
||||
|
||||
Util::appendToMetricsFile("Screenplay_app_qqmlapplicationengine_load_begin", m_continuousIntegrationMetricsTimer.msecsSinceReference());
|
||||
m_mainWindowEngine->load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||
Util::appendToMetricsFile("Screenplay_app_qqmlapplicationengine_load_end", m_continuousIntegrationMetricsTimer.msecsSinceReference());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -35,6 +35,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDir>
|
||||
#include <QElapsedTimer>
|
||||
#include <QIcon>
|
||||
#include <QObject>
|
||||
#include <QQmlApplicationEngine>
|
||||
@ -252,6 +253,7 @@ public slots:
|
||||
private:
|
||||
QPluginLoader m_workshopPlugin;
|
||||
QNetworkAccessManager m_networkAccessManager;
|
||||
QElapsedTimer m_continuousIntegrationMetricsTimer;
|
||||
std::unique_ptr<QQmlApplicationEngine> m_mainWindowEngine;
|
||||
|
||||
std::unique_ptr<Create> m_create;
|
||||
|
@ -34,10 +34,15 @@
|
||||
|
||||
#include "app.h"
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QDebug>
|
||||
#ifdef Q_OS_WIN
|
||||
#include <sentry.h>
|
||||
#endif
|
||||
#define DOCTEST_CONFIG_IMPLEMENT
|
||||
#define DOCTEST_CONFIG_SUPER_FAST_ASSERTS
|
||||
#include <doctest/doctest.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
@ -52,6 +57,12 @@ int main(int argc, char* argv[])
|
||||
|
||||
QApplication qtGuiApp(argc, argv);
|
||||
|
||||
if (QGuiApplication::arguments().contains("--benchmark")) {
|
||||
QFile metricsFile { QGuiApplication::applicationDirPath() + "/metrics.txt" };
|
||||
if (metricsFile.exists())
|
||||
qInfo() << "Removing old Continuous Integration Metrics Timer: " << metricsFile.remove();
|
||||
}
|
||||
|
||||
ScreenPlay::App app;
|
||||
|
||||
if (app.m_isAnotherScreenPlayInstanceRunning) {
|
||||
|
@ -168,13 +168,34 @@ QString Util::toString(const QStringList& list)
|
||||
return out;
|
||||
}
|
||||
|
||||
void Util::appendToMetricsFile(const QString& key, const QVariant& value)
|
||||
{
|
||||
if (!QGuiApplication::arguments().contains("--benchmark"))
|
||||
return;
|
||||
|
||||
const QString appDir = QGuiApplication::applicationDirPath();
|
||||
QFile metricsFile { appDir + "/metrics.txt" };
|
||||
|
||||
if (!metricsFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) {
|
||||
qWarning() << "Cannot open metrix file:" << appDir << metricsFile.fileName();
|
||||
return;
|
||||
}
|
||||
|
||||
QString text = key + "\t" + value.toString() + "\n";
|
||||
QTextStream out(&metricsFile);
|
||||
out << text;
|
||||
|
||||
metricsFile.flush();
|
||||
metricsFile.close();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Parses a QByteArray to a QJsonObject. If returns and std::nullopt on failure.
|
||||
*/
|
||||
std::optional<QJsonObject> Util::parseQByteArrayToQJsonObject(const QByteArray& byteArray)
|
||||
{
|
||||
QJsonObject obj;
|
||||
QJsonParseError err;
|
||||
QJsonParseError err {};
|
||||
QJsonDocument doc = QJsonDocument::fromJson(byteArray, &err);
|
||||
|
||||
if (err.error == QJsonParseError::NoError) {
|
||||
|
@ -113,6 +113,7 @@ public slots:
|
||||
static std::optional<QVersionNumber> getVersionNumberFromString(const QString& str);
|
||||
static bool writeJsonObjectToFile(const QString& absoluteFilePath, const QJsonObject& object, bool truncate = true);
|
||||
static QString toString(const QStringList& list);
|
||||
static void appendToMetricsFile(const QString& key, const QVariant& value);
|
||||
|
||||
static void logToGui(QtMsgType type, const QMessageLogContext& context, const QString& msg);
|
||||
static QString generateRandomString(quint32 length = 32);
|
||||
|
Loading…
Reference in New Issue
Block a user