Skip to content

Commit

Permalink
qgis_bench wall clock time
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Apr 4, 2013
1 parent 8b1eb78 commit 9b83d1a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 10 additions & 8 deletions tests/bench/qgsbench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ void QgsBench::render()
mLogMap.insert( "iterations", mTimes.size() );

// Calc stats: user, sys, total
double min[3], max[3];
double stdev[3] = {0.};
double maxdev[3] = {0.};
double avg[3] = {0.};
double min[4], max[4];
double stdev[4] = {0.};
double maxdev[4] = {0.};
double avg[4] = {0.};

for ( int t = 0; t < 3; t++ )
for ( int t = 0; t < 4; t++ )
{
for ( int i = 0; i < mTimes.size(); i++ )
{
Expand All @@ -228,7 +228,7 @@ void QgsBench::render()
}

QMap<QString, QVariant> timesMap;
for ( int t = 0; t < 3; t++ )
for ( int t = 0; t < 4; t++ )
{
if ( mIterations > 1 )
{
Expand All @@ -242,7 +242,7 @@ void QgsBench::render()
stdev[t] = sqrt( stdev[t] / mTimes.size() );
}

const char *pre[] = { "user", "sys", "total" } ;
const char *pre[] = { "user", "sys", "total", "wall" };

QMap<QString, QVariant> map;

Expand Down Expand Up @@ -322,6 +322,7 @@ void QgsBench::start()
getrusage( RUSAGE_SELF, &usage );
mUserStart = usage.ru_utime.tv_sec + usage.ru_utime.tv_usec / 1000000.;
mSysStart = usage.ru_stime.tv_sec + usage.ru_stime.tv_usec / 1000000.;
mWallTime.start();
}

void QgsBench::elapsed()
Expand All @@ -332,9 +333,10 @@ void QgsBench::elapsed()
double userEnd = usage.ru_utime.tv_sec + usage.ru_utime.tv_usec / 1000000.;
double sysEnd = usage.ru_stime.tv_sec + usage.ru_stime.tv_usec / 1000000.;

double *t = new double[3];
double *t = new double[4];
t[0] = userEnd - mUserStart;
t[1] = sysEnd - mSysStart;
t[2] = t[0] + t[1];
t[3] = mWallTime.elapsed() / 1000.;
mTimes.append( t );
}
2 changes: 2 additions & 0 deletions tests/bench/qgsbench.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QMap>
#include <QPainter>
#include <QString>
#include <QTime>
#include <QVariant>
#include <QVector>

Expand Down Expand Up @@ -81,6 +82,7 @@ class QgsBench : public QObject

double mUserStart;
double mSysStart;
QTime mWallTime; // 'wall clock' time

// user, sys, total times
QVector<double*> mTimes;
Expand Down

0 comments on commit 9b83d1a

Please sign in to comment.