From 1ab6dc39778ea3379f3c626104726935be3804db Mon Sep 17 00:00:00 2001 From: Mika Salmela Date: Mon, 8 Dec 2014 13:24:27 +0200 Subject: Write fps to file. Change-Id: I303c243b25da0003ca86e5085b913f54a14dc86f Reviewed-by: Mika Salmela --- tests/qmlperf/datagenerator.cpp | 21 ++++++++++++++++++++- tests/qmlperf/datagenerator.h | 3 +++ tests/qmlperf/qml/qmlperf/main.qml | 20 ++++++++++++++++---- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/tests/qmlperf/datagenerator.cpp b/tests/qmlperf/datagenerator.cpp index 28056234..199664a6 100644 --- a/tests/qmlperf/datagenerator.cpp +++ b/tests/qmlperf/datagenerator.cpp @@ -27,11 +27,18 @@ DataGenerator::DataGenerator(QObject *parent) : QObject(parent) { qRegisterMetaType(); + + m_file = new QFile("results.txt"); + if (!m_file->open(QIODevice::WriteOnly | QIODevice::Text)) { + delete m_file; + m_file = 0; + } } DataGenerator::~DataGenerator() { - qDebug() << __FUNCTION__; + m_file->close(); + delete m_file; } void DataGenerator::generateData(QScatter3DSeries *series, uint count) @@ -65,3 +72,15 @@ void DataGenerator::add(QScatter3DSeries *series, uint count) series->dataProxy()->addItems(appendArray); } + +void DataGenerator::writeLine(int itemCount, float fps) +{ + if (m_file) { + QTextStream out(m_file); + + QString fpsFormatString(QStringLiteral("%1 %2\n")); + QString fpsString = fpsFormatString.arg(itemCount).arg(fps); + + out << fpsString; + } +} diff --git a/tests/qmlperf/datagenerator.h b/tests/qmlperf/datagenerator.h index c066d80c..ee40b13e 100644 --- a/tests/qmlperf/datagenerator.h +++ b/tests/qmlperf/datagenerator.h @@ -20,6 +20,7 @@ #define DATAGENERATOR_H #include +#include using namespace QtDataVisualization; @@ -33,9 +34,11 @@ public: public slots: void generateData(QScatter3DSeries *series, uint count); void add(QScatter3DSeries *series, uint count); + void writeLine(int itemCount, float fps); private: QScatter3DSeries m_series; + QFile *m_file; }; #endif // DATAGENERATOR_H diff --git a/tests/qmlperf/qml/qmlperf/main.qml b/tests/qmlperf/qml/qmlperf/main.qml index 138d3970..6daaad8e 100644 --- a/tests/qmlperf/qml/qmlperf/main.qml +++ b/tests/qmlperf/qml/qmlperf/main.qml @@ -32,7 +32,7 @@ Rectangle { Button { id: changeButton - width: parent.width / 6 + width: parent.width / 7 height: 50 anchors.left: parent.left enabled: true @@ -54,7 +54,7 @@ Rectangle { Text { id: fpsText text: "Reading" - width: parent.width / 2 + width: (parent.width / 7) * 3 height: 50 anchors.left: changeButton.right verticalAlignment: Text.AlignVCenter @@ -63,7 +63,7 @@ Rectangle { Button { id: optimization - width: parent.width / 6 + width: parent.width / 7 height: 50 anchors.left: fpsText.right enabled: true @@ -82,7 +82,7 @@ Rectangle { Button { id: itemAdd - width: parent.width / 6 + width: parent.width / 7 height: 50 anchors.left: optimization.right enabled: true @@ -93,6 +93,18 @@ Rectangle { } } + Button { + id: writeLine + width: parent.width / 7 + height: 50 + anchors.left: itemAdd.right + enabled: true + text: "Write" + onClicked: { + dataGenerator.writeLine(itemCount, scatterPlot.currentFps.toFixed(1)); + } + } + Item { id: graphView width: mainview.width -- cgit v1.2.3