Re: [sqlite] Is there a way to measure query time in sqlite at runtime?

2012-11-17 Thread Simon Slavin

On 16 Nov 2012, at 11:26pm, 杨苏立 Yang Su Li  wrote:

> I want to measure the execution time of each sql statement in sqlite.
> 
> I understand in sqlite shell you could just do .timer on, but I am
> wondering how to do it in a pogrammerable way so that I could know how much
> time a sql statement takes when applications are accessing the database at
> real time, not just by replaying that statement in a shell afterwards?
> 
> Could I just provide a plugin function for sqlite_profile?

While you can use the built-in functions to do this, as Kyan showed you, it is 
more accurate to do it in your own programming language, since those times will 
include the overhead for calling the SQLite functions and handling memory.  If 
you are calling the raw C API functions that overhead is low, but if you are 
using an object-oriented library it can be high.

If your language has a 'get time of day as a number' function then you can just 
use that before and after each SQLite call and subtract one from another.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Is there a way to measure query time in sqlite at runtime?

2012-11-17 Thread kyan
On Sat, Nov 17, 2012 at 1:26 AM, 杨苏立 Yang Su Li  wrote:
> I want to measure the execution time of each sql statement in sqlite.

Use sqlite3_profile() to register a profiler callback for a database
connection that will be called for every SQL statement you execute on
that connection.

http://www.sqlite.org/c3ref/profile.html

HTH.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Is there a way to measure query time in sqlite at runtime?

2012-11-17 Thread 杨苏立 Yang Su Li
I want to measure the execution time of each sql statement in sqlite.

I understand in sqlite shell you could just do .timer on, but I am
wondering how to do it in a pogrammerable way so that I could know how much
time a sql statement takes when applications are accessing the database at
real time, not just by replaying that statement in a shell afterwards?

Could I just provide a plugin function for sqlite_profile?

Thanks a lot


Suli

-- 
Suli Yang

Department of Physics
University of Wisconsin Madison

4257 Chamberlin Hall
Madison WI 53703
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users