From f92240a80c1afc45005c8fa39ce04f34dae45dff Mon Sep 17 00:00:00 2001
From: Daniel Smith <daniel.smith@qt.io>
Date: Thu, 13 Dec 2018 10:38:32 +0100
Subject: [PATCH] WIP: update frametime to print with QDebug

---
 Heavy_QML_example.pro      |  2 +-
 Heavy_QML_example.pro.user |  2 +-
 benchmark.cpp              | 24 ++++++++++++++++++++----
 benchmark.h                |  7 ++++---
 4 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/Heavy_QML_example.pro b/Heavy_QML_example.pro
index f48e6a0..4c04d5b 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 6117eff..8c6c861 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 e5725d1..db10c9c 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 898e383..25b2a39 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());
 };
 
 
-- 
GitLab