void test(){ const int rowNumber=1000000; //SQL test QSqlDatabase myBase=QSqlDatabase::addDatabase("QSQLITE"); myBase.setDatabaseName("testBase"); myBase.open(); QSqlQuery query; query.exec("DROP TABLE testTable"); query.exec("CREATE TABLE testTable(field1 INTEGER PRIMARY KEY,field2 INTEGER)"); myBase.transaction(); QSqlQuery insert; insert.prepare("INSERT INTO testTable (field1,field2) VALUES(?,?)"); QTime time; time.start(); for(int i=0;i<rowNumber;++i) { insert.addBindValue(QVariant(i)); insert.addBindValue(QVariant(i)); insert.exec(); } myBase.commit(); qDebug()<<"SQL time = "<<time.elapsed(); myBase.close(); //qMap test time.start(); QFile F("testFile"); F.open(QIODevice::WriteOnly); QDataStream stream(&F); QMap<int,int>testMap; for(int i=0;i<rowNumber;++i) testMap[i]=i; stream<<testMap; F.close(); qDebug()<<"map time = "<<time.elapsed();}
SQLCREATE TABLE testTable(field1 INTEGER PRIMARY KEY,field2 INTEGER)
C++ (Qt)QSqlDriver::hasFeature(QSqlDriver::PreparedQueries)
C++ (Qt)QSqlDriver::BatchOperationsQSqlDriver::Transactions