Re: [sqlite] Seems that '-cmd .timer on' does not work in non interactive mode

2017-02-15 Thread David Raymond
I'm probably not the best to answer this since I don't know C, but the timing 
results are printed out in their own special thing.

The BEGIN_TIMER and END_TIMER functions only get used in the runOneSqlLine 
function, and inside the END_TIMER function is where the results actually get 
printed with a straight up printf that doesn't use any sort of shell callback. 
Any statements run through -cmd only get run through shell_exec there, without 
the BEGIN_TIMER or END_TIMER around them. I  then that simply adding 
those in before and after the shell_exec (line 6086 in shell.c) in the -cmd 
section will work, but I don't know for sure. Try it and let us know :)


--

/*
** Run a single line of SQL
*/
static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){
...
  BEGIN_TIMER;
  rc = shell_exec(p->db, zSql, shell_callback, p, );
  END_TIMER;
...

--

/*
** Print the timing results.
*/
static void endTimer(void){
  if( enableTimer ){
sqlite3_int64 iEnd = timeOfDay();
struct rusage sEnd;
getrusage(RUSAGE_SELF, );
printf("Run Time: real %.3f user %f sys %f\n",
   (iEnd - iBegin)*0.001,
   timeDiff(_utime, _utime),
   timeDiff(_stime, _stime));
  }
}
#define END_TIMER endTimer()

--

...

}else if( strcmp(z,"-cmd")==0 ){
  /* Run commands that follow -cmd first and separately from commands
  ** that simply appear on the command-line.  This seems goofy.  It would
  ** be better if all commands ran in the order that they appear.  But
  ** we retain the goofy behavior for historical compatibility. */
...
open_db(, 0);
rc = shell_exec(data.db, z, shell_callback, , );
if( zErrMsg!=0 ){
...




-Original Message-
From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On 
Behalf Of Cecil Westerhof
Sent: Wednesday, February 15, 2017 7:05 AM
To: SQLite mailing list
Subject: [sqlite] Seems that '-cmd .timer on' does not work in non interactive 
mode

I want to do some timings. So I started with the following:
sqlite3 -cmd '.timer on' ~/Databases/general.sqlite '
SELECT date
,  time
,  usertime
,  systemtime
,  idletime
,  waittime
,  stolentime
,  (usertime + systemtime + idletime + waittime + stolentime) AS
totaltime
FROM   vmstat
WHERE  totaltime  < 99 OR totaltime > 101
;'

​This does display the query result, but not the runtime.

At the moment I just start sqlite with:
sqlite3 -cmd '.timer on' ~/Databases/general.sqlite

and then interactively enter:
SELECT date
,  time
,  usertime
,  systemtime
,  idletime
,  waittime
,  stolentime
,  (usertime + systemtime + idletime + waittime + stolentime) AS
totaltime
FROM   vmstat
WHERE  totaltime  < 99 OR totaltime > 101
;

I get beside the query result also:
Run Time: real 0.298 user 0.264000 sys 0.036000
​
​What is happening here?


I got around it with:
sqlite3 -batch -cmd '.timer on' ~/Databases/general.sqlite < 101
;
EOT
​
-- 
Cecil Westerhof
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Seems that '-cmd .timer on' does not work in non interactive mode

2017-02-15 Thread Cecil Westerhof
I want to do some timings. So I started with the following:
sqlite3 -cmd '.timer on' ~/Databases/general.sqlite '
SELECT date
,  time
,  usertime
,  systemtime
,  idletime
,  waittime
,  stolentime
,  (usertime + systemtime + idletime + waittime + stolentime) AS
totaltime
FROM   vmstat
WHERE  totaltime  < 99 OR totaltime > 101
;'

​This does display the query result, but not the runtime.

At the moment I just start sqlite with:
sqlite3 -cmd '.timer on' ~/Databases/general.sqlite

and then interactively enter:
SELECT date
,  time
,  usertime
,  systemtime
,  idletime
,  waittime
,  stolentime
,  (usertime + systemtime + idletime + waittime + stolentime) AS
totaltime
FROM   vmstat
WHERE  totaltime  < 99 OR totaltime > 101
;

I get beside the query result also:
Run Time: real 0.298 user 0.264000 sys 0.036000
​
​What is happening here?


I got around it with:
sqlite3 -batch -cmd '.timer on' ~/Databases/general.sqlite < 101
;
EOT
​
-- 
Cecil Westerhof
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users