Added time measurement

This commit is contained in:
Michael Mandl 2015-10-26 09:19:48 +01:00
parent 24b6969ab7
commit 22dba2cb27

View file

@ -1,10 +1,14 @@
#include "netlearner.h" #include "netlearner.h"
#include "../../Net.h" #include "../../Net.h"
#include <QElapsedTimer>
void NetLearner::run() void NetLearner::run()
{ {
try try
{ {
QElapsedTimer timer;
Net myNet({2, 3, 1}); Net myNet({2, 3, 1});
size_t batchSize = 5000; size_t batchSize = 5000;
@ -12,6 +16,8 @@ void NetLearner::run()
double batchMaxError = 0.0; double batchMaxError = 0.0;
double batchMeanError = 0.0; double batchMeanError = 0.0;
timer.start();
size_t numIterations = 1000000; size_t numIterations = 1000000;
for (size_t iteration = 0; iteration < numIterations; ++iteration) for (size_t iteration = 0; iteration < numIterations; ++iteration)
{ {
@ -59,6 +65,13 @@ void NetLearner::run()
emit progress((double)iteration / (double)numIterations); emit progress((double)iteration / (double)numIterations);
} }
QString timerLogString;
timerLogString.append("Elapsed time: ");
timerLogString.append(QString::number(timer.elapsed() / 1000.0));
timerLogString.append(" seconds");
emit logMessage(timerLogString);
myNet.save("mynet.nnet"); myNet.save("mynet.nnet");
} }
catch (std::exception &ex) catch (std::exception &ex)