Poco::Data::Session sess("SQLite", "test.db"); sess << "create table if not exists test (" "[col_a] NVARCHAR(256) NOT NULL," "[col_b] NVARCHAR(256) NOT NULL)", Poco::Data::Keywords::now;
DWORD tick = GetTickCount(); sess.begin(); for (size_t i = 0; i < 1000000; i++) { char bufa[64] = { 0 }; char bufb[64] = { 0 }; sprintf(bufa, "test col a %d %d", i, rand()); sprintf(bufb, "test col b %d %d", i*2, rand());
sess << "insert into test(col_a,col_b) values(?,?)", Poco::Data::Keywords::use(bufa), Poco::Data::Keywords::use(bufb), Poco::Data::Keywords::now; }
sess.commit(); DWORD n = GetTickCount() - tick; std::cout << n << std::endl;
DWORD tick = GetTickCount(); std::list<std::string> a, b; for (size_t i = 0; i < 1000000; i++) { char bufa[64] = { 0 }; char bufb[64] = { 0 }; sprintf(bufa, "test col a %d %d", i, rand()); sprintf(bufb, "test col b %d %d", i * 2, rand()); a.push_back(bufa); b.push_back(bufb); }
sess << "insert into test(col_a,col_b) values(?,?)", Poco::Data::Keywords::use(a), Poco::Data::Keywords::use(b), Poco::Data::Keywords::now;
DWORD n = GetTickCount() - tick; std::cout << n << std::endl;