Skip to content

Commit

Permalink
avoid gettimeofday
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Aug 10, 2012
1 parent d746aca commit 2d473c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
10 changes: 4 additions & 6 deletions src/core/symbology-ng/qgsvectorcolorrampv2.cpp
Expand Up @@ -21,7 +21,7 @@
#include "qgslogger.h"

#include <stdlib.h> // for random()
#include <sys/time.h>
#include <QTime>

QgsVectorGradientColorRampV2::QgsVectorGradientColorRampV2( QColor color1, QColor color2 )
: mColor1( color1 ), mColor2( color2 )
Expand Down Expand Up @@ -763,8 +763,8 @@ bool QgsCptCityColorRampV2::hasAllSchemes()
// currently this method takes some time, so it must be explicitly requested
bool QgsCptCityColorRampV2::loadSchemes( QString rootDir, bool reset )
{
struct timeval tv1, tv2;
gettimeofday( &tv1, 0 );
QTime time;
time.start();

// TODO should keep the name of the previously loaded, or see if the first element is inside rootDir
if ( ! reset && ! mCollections.isEmpty() )
Expand Down Expand Up @@ -987,9 +987,7 @@ bool QgsCptCityColorRampV2::loadSchemes( QString rootDir, bool reset )
mCollectionSelections[ viewName ] << curName;
}

gettimeofday( &tv2, 0 );
QgsDebugMsg( QString( "done in %1.%2 seconds" ).arg( tv2.tv_sec - tv1.tv_sec
).arg(( double )( tv2.tv_usec - tv2.tv_usec ) / 1000000.0 ) );
QgsDebugMsg( QString( "done in %1 seconds" ).arg( time.elapsed() / 1000.0 ) );
return ( ! mCollections.isEmpty() );
}

12 changes: 4 additions & 8 deletions src/gui/symbology-ng/qgscptcitycolorrampv2dialog.cpp
Expand Up @@ -22,8 +22,7 @@

#include <QPushButton>
#include <QTextEdit>

#include <sys/time.h>
#include <QTime>

/////////

Expand Down Expand Up @@ -180,8 +179,8 @@ void QgsCptCityColorRampV2Dialog::populateSchemes( QString view )
QStringList collections;
QTreeWidgetItem *item, *childItem;

struct timeval tv1, tv2;
gettimeofday( &tv1, 0 );
QTime time;
time.start();

treeWidget->blockSignals( true );
treeWidget->clear();
Expand Down Expand Up @@ -238,10 +237,7 @@ void QgsCptCityColorRampV2Dialog::populateSchemes( QString view )

treeWidget->setColumnWidth( 0, 250 );

gettimeofday( &tv2, 0 );
QgsDebugMsg( QString( "done in %1.%2 seconds" ).arg( tv2.tv_sec - tv1.tv_sec
).arg(( double )( tv2.tv_usec - tv2.tv_usec ) / 1000000.0 ) );

QgsDebugMsg( QString( "done in %1 seconds" ).arg( time.elapsed() / 1000.0 ) );
}

void QgsCptCityColorRampV2Dialog::populateVariants()
Expand Down

0 comments on commit 2d473c5

Please sign in to comment.