diff --git a/Heavy_QML_example.pro b/Heavy_QML_example.pro index f48e6a0735fbe6b70a7b10131dd97d95f75ab77a..4c04d5bfae7bb5c1bc274e2064cbe223b1434156 100644 --- a/Heavy_QML_example.pro +++ b/Heavy_QML_example.pro @@ -1,4 +1,4 @@ -QT += quick +QT += quick opengl CONFIG += c++11 # The following define makes your compiler emit warnings if you use diff --git a/Heavy_QML_example.pro.user b/Heavy_QML_example.pro.user index 6117effbf10cb696c8caebdd463e9a3417f4c069..8c6c8613e6c4e352b63094572514c5df6c4c08b4 100644 --- a/Heavy_QML_example.pro.user +++ b/Heavy_QML_example.pro.user @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE QtCreatorProject> -<!-- Written by QtCreator 4.8.0, 2018-12-12T16:24:04. --> +<!-- Written by QtCreator 4.8.0, 2018-12-13T10:03:53. --> <qtcreator> <data> <variable>EnvironmentId</variable> diff --git a/benchmark.cpp b/benchmark.cpp index e5725d14e61e670d78e35d1d1ddd616ef20a182e..db10c9c6287bdcd7fd7f078ecb001e762878c387 100644 --- a/benchmark.cpp +++ b/benchmark.cpp @@ -7,7 +7,6 @@ #include <QQuickWindow> #include <QGuiApplication> - void Benchmark::startTimer(){ } @@ -21,15 +20,32 @@ void Benchmark::countFrame(){ printf("frame."); //No need to handle this. We probably just rendered extra frames before finished() completed. } - printf("frame %d: %d ms\n", frame, thisframe); + qDebug() << "frame " << frame << ": " << thisframe << " ms"; frame+=1; if (frame >= maxframes){ this->finished(); } } -void Benchmark::measureFrame(qint64 value){ - printf("%d,", static_cast<int>(value)); +void Benchmark::measureMem(){ +#ifdef _WIN32 + //define something for Windows (32-bit and 64-bit, this part is common) +#elif __APPLE__ + #include "TargetConditionals.h" + #if TARGET_IPHONE_SIMULATOR + // iOS Simulator + #elif TARGET_OS_IPHONE + // iOS device + #elif TARGET_OS_MAC + // Other kinds of Mac OS + #else + # error "Unknown Apple platform" + #endif +#elif __linux__ + // linux +#else +# error "Unknown compiler" +#endif } void Benchmark::finished(){ diff --git a/benchmark.h b/benchmark.h index 898e383e008949a1ed3956d2d557bb85277f9094..25b2a39b38f8032778f03a91220425a0242b7f1c 100644 --- a/benchmark.h +++ b/benchmark.h @@ -4,6 +4,7 @@ #include <QObject> #include <QGuiApplication> #include <QElapsedTimer> +#include <QCoreApplication> class Benchmark: public QObject{ @@ -18,12 +19,12 @@ class Benchmark: public QObject{ QElapsedTimer timer; int frame = 0; int lastframetotal; - static const int maxframes = 120; + static const int maxframes = 300; int frametimes [maxframes]; void finished(); void startTimer(); - void measureFrame(qint64); - + void measureMem(); + const int processID = static_cast<int>(QCoreApplication::applicationPid()); };