#include <stdio.h> #pragma comment(lib,"sqlite3static.lib") #include "sqlite3.h" #include <iostream> using namespace std; #include <ctime> char value[100]; int main(void) { clock_t startclock,endclock; sqlite3* db = 0; /*************************************************************************/ sqlite3_open("MyDB",&db); sqlite3_exec(db,"create table Student(english QString)",0); /*situation 1*/ startclock=clock(); sqlite3_exec(db,"begin",0); for(int i=0;i<100;i++) { sprintf(value,"insert into Student values(%d)",i); sqlite3_exec(db,value,0); } sqlite3_exec(db,"commit",0); endclock=clock(); cout<<(double)(endclock-startclock)/CLOCKS_PER_SEC<<endl; sqlite3_close(db); /***************************************************************************/ sqlite3_open("MyDB1",0); /* situation 2*/ startclock=clock(); for(int i=0;i<100;i++) { sprintf(value,0); } endclock=clock(); cout<<(double)(endclock-startclock)/CLOCKS_PER_SEC<<endl; sqlite3_close(db); /*****************************************************************************/ return 0; } |