1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10:24:11 +01:00

OP37/GCS MapLib - Try different DB method to improve speed.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2694 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
zedamota 2011-02-02 10:41:27 +00:00 committed by zedamota
parent 986e124202
commit 878829a7cf
4 changed files with 21 additions and 6 deletions

View File

@ -26,6 +26,6 @@
*/ */
#include "diagnostics.h" #include "diagnostics.h"
diagnostics::diagnostics():networkerrors(0),emptytiles(0),timeouts(0),runningThreads(0) diagnostics::diagnostics():networkerrors(0),emptytiles(0),timeouts(0),runningThreads(0),tilesFromMem(0),tilesFromNet(0),tilesFromDB(0)
{ {
} }

View File

@ -34,9 +34,13 @@ struct diagnostics
int emptytiles; int emptytiles;
int timeouts; int timeouts;
int runningThreads; int runningThreads;
int tilesFromMem;
int tilesFromNet;
int tilesFromDB;
QString toString() QString toString()
{ {
return QString("Network errors:%1\nEmpty Tiles:%2\nTimeOuts:%3\nRunningThreads:%4").arg(networkerrors).arg(emptytiles).arg(timeouts).arg(runningThreads); return QString("Network errors:%1\nEmpty Tiles:%2\nTimeOuts:%3\nRunningThreads:%4\nTilesFromMem:%5\nTilesFromNet:%6\nTilesFromDB:%7").arg(networkerrors).arg(emptytiles).arg(timeouts).arg(runningThreads).arg(tilesFromMem).arg(tilesFromNet).arg(tilesFromDB);
;
} }
}; };

View File

@ -70,6 +70,12 @@ namespace core {
qDebug()<<"Try Tile from memory:Size="<<TilesInMemory.MemoryCacheSize(); qDebug()<<"Try Tile from memory:Size="<<TilesInMemory.MemoryCacheSize();
#endif //DEBUG_GMAPS #endif //DEBUG_GMAPS
ret=GetTileFromMemoryCache(RawTile(type,pos,zoom)); ret=GetTileFromMemoryCache(RawTile(type,pos,zoom));
if(!ret.isEmpty())
{
errorvars.lock();
++diag.tilesFromMem;
errorvars.unlock();
}
} }
if(ret.isEmpty()) if(ret.isEmpty())
@ -85,6 +91,9 @@ namespace core {
ret=Cache::Instance()->ImageCache.GetImageFromCache(type,pos,zoom); ret=Cache::Instance()->ImageCache.GetImageFromCache(type,pos,zoom);
if(!ret.isEmpty()) if(!ret.isEmpty())
{ {
errorvars.lock();
++diag.tilesFromDB;
errorvars.unlock();
#ifdef DEBUG_GMAPS #ifdef DEBUG_GMAPS
qDebug()<<"Tile found in Database"; qDebug()<<"Tile found in Database";
#endif //DEBUG_GMAPS #endif //DEBUG_GMAPS
@ -228,6 +237,9 @@ namespace core {
#ifdef DEBUG_GMAPS #ifdef DEBUG_GMAPS
qDebug()<<"Received Tile from the Internet"; qDebug()<<"Received Tile from the Internet";
#endif //DEBUG_GMAPS #endif //DEBUG_GMAPS
errorvars.lock();
++diag.tilesFromNet;
errorvars.unlock();
if (useMemoryCache) if (useMemoryCache)
{ {
#ifdef DEBUG_GMAPS #ifdef DEBUG_GMAPS

View File

@ -194,11 +194,11 @@ namespace core {
qlonglong id=++ConnCounter; qlonglong id=++ConnCounter;
Mcounter.unlock(); Mcounter.unlock();
{ {
Mcounter.lock();
QSqlDatabase cn; QSqlDatabase cn;
cn = QSqlDatabase::addDatabase("QSQLITE",QString::number(id)); cn = QSqlDatabase::addDatabase("QSQLITE",QString::number(id));
QString db=gtilecache+"Data.qmdb"; QString db=gtilecache+"Data.qmdb";
cn.setDatabaseName(db); cn.setDatabaseName(db);
cn.setConnectOptions("QSQLITE_ENABLE_SHARED_CACHE");
if(cn.open()) if(cn.open())
{ {
{ {
@ -220,7 +220,6 @@ namespace core {
} }
cn.close(); cn.close();
} }
Mcounter.unlock();
} }
QSqlDatabase::removeDatabase(QString::number(id)); QSqlDatabase::removeDatabase(QString::number(id));
return true; return true;
@ -239,12 +238,12 @@ namespace core {
{ {
QString db=dir+"Data.qmdb"; QString db=dir+"Data.qmdb";
{ {
Mcounter.lock();
QSqlDatabase cn; QSqlDatabase cn;
cn = QSqlDatabase::addDatabase("QSQLITE",QString::number(id)); cn = QSqlDatabase::addDatabase("QSQLITE",QString::number(id));
cn.setDatabaseName(db); cn.setDatabaseName(db);
cn.setConnectOptions("QSQLITE_ENABLE_SHARED_CACHE");
if(cn.open()) if(cn.open())
{ {
{ {
@ -258,7 +257,6 @@ namespace core {
} }
cn.close(); cn.close();
} }
Mcounter.unlock();
} }
} }
QSqlDatabase::removeDatabase(QString::number(id)); QSqlDatabase::removeDatabase(QString::number(id));
@ -280,6 +278,7 @@ namespace core {
Mcounter.unlock(); Mcounter.unlock();
cn = QSqlDatabase::addDatabase("QSQLITE",QString::number(id)); cn = QSqlDatabase::addDatabase("QSQLITE",QString::number(id));
cn.setDatabaseName(db); cn.setDatabaseName(db);
cn.setConnectOptions("QSQLITE_ENABLE_SHARED_CACHE");
if(cn.open()) if(cn.open())
{ {
{ {