Skip to content
Permalink
Browse files

avoid gettimeofday

  • Loading branch information
jef-n committed Aug 10, 2012
1 parent d746aca commit 2d473c524e0ddf7264a5bd1b4a215182cc4b76ac
@@ -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 )
@@ -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() )
@@ -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() );
}

@@ -22,8 +22,7 @@

#include <QPushButton>
#include <QTextEdit>

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

/////////

@@ -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();
@@ -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()

0 comments on commit 2d473c5

Please sign in to comment.
You can’t perform that action at this time.