I change my code to make it clear.
- (double)now
{
struct timeval time;
gettimeofday(time, NULL);
double ms = time.tv_sec+time.tv_usec/1000000.0;
return ms;
}
- (void)test
{
...
double before = [self now];
sqlite3_exec(handle, "SELECT * FROM testtable", NULL, NULL, NULL);
double after = [self now];
sqlite3_close(handle);
double cost = after-before;
NSLog(@"cost %f begin %f after %f", cost, before, after);
}
1-thread result,
2015-11-02 11:10:04.670 TestSQLite[1663:591258] cost 0.105395 begin
1446433804.564858 after 1446433804.670253
4-threads result,
2015-11-02 11:10:41.484 TestSQLite[1666:591636] cost 0.150516 begin
1446433841.333576 after 1446433841.484092
2015-11-02 11:10:41.540 TestSQLite[1666:591635] cost 0.199100 begin
1446433841.341357 after 1446433841.540457
2015-11-02 11:10:41.540 TestSQLite[1666:591637] cost 0.188056 begin
1446433841.351582 after 1446433841.539638
2015-11-02 11:10:41.564 TestSQLite[1666:591638] cost 0.166090 begin
1446433841.397650 after 1446433841.563740
????
???:Simon Slavinslavins at bigfraud.org
???:SQLite mailing listsqlite-users at mailinglists.sqlite.org
????:2015?11?2?(??)?10:47
??:Re: [sqlite] Why SQLite take lower performance inmulti-threadSELECTing?
On 2 Nov 2015, at 2:45am, Simon Slavin slavins at bigfraud.org wrote: There's
nothing wrong with your code. Well actually there is (you don't test the values
returned by all the SQLite calls) but that will not affect what we're
discussing. Okay, I see how you do this now: you use the log trap to do it. I
don't know whether that works properly but it should not affect timing either
way. Simon. _______________________________________________ sqlite-users
mailing list sqlite-users at mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users