Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Illuminatus is correct - the time comes from the mysql command client.

Not that it helps the OP, but I was interested in finding out about this (and one of the key points of Open Source is that you CAN look at the source!)

(Based on MySQL 5.0.51a, OpenBSD port)

client/mysql.cc

(around line 2049)
static int com_go(String *buffer,char *line __attribute__((unused))) { char buff[200], time_buff[32], *pos;
(line 2092)  timer=start_timer();

(line 2137)      mysql_end_timer(timer,time_buff);

(line 2170 - the "n rows in set" message)
sprintf(buff,"%ld %s in set", (long) mysql_num_rows(result), (long) mysql_num_rows(result) == 1 ? "row" : "rows");
(line 2195)     strmov(pos, time_buff);

So, what does mysql_end_timer put in time_buff?

(line 3726, same file, builds the "(" and ")", calling nice_time for the seconds display)
static void end_timer(ulong start_time,char *buff) { nice_time((double) (start_timer() - start_time) / CLOCKS_PER_SEC,buff,1); } static void mysql_end_timer(ulong start_time,char *buff) { buff[0]=' '; buff[1]='('; end_timer(start_time,buff+2); strmov(strend(buff),")"); }
(line 3695 - builds the "n sec" part)
static void nice_time(double sec,char *buff,bool part_second) { ulong tmp; if (sec >= 3600.0*24) { tmp=(ulong) floor(sec/(3600.0*24)); sec-=3600.0*24*tmp; buff=int10_to_str((long) tmp, buff, 10); buff=strmov(buff,tmp > 1 ? " days " : " day "); } if (sec >= 3600.0) { tmp=(ulong) floor(sec/3600.0); sec-=3600.0*tmp; buff=int10_to_str((long) tmp, buff, 10); buff=strmov(buff,tmp > 1 ? " hours " : " hour "); } if (sec >= 60.0) { tmp=(ulong) floor(sec/60.0); sec-=60.0*tmp; buff=int10_to_str((long) tmp, buff, 10); buff=strmov(buff," min "); } if (part_second) sprintf(buff,"%.2f sec",sec); else sprintf(buff,"%d sec",(int) sec); }
And, so, finally, what does start_timer() do? (line 3684)
static ulong start_timer(void) { #if defined( __WIN__) || defined( OS2) || defined(__NETWARE__) return clock(); #else struct tms tms_tmp; return times(&tms_tmp); #endif }
Assuming we are not running on WIN/OS2/NETWARE, we can see what times does:

http://www.openbsd.org/cgi-bin/man.cgi?query=times&apropos=0&sektion=0&manpath=OpenBSD+Current&arch=i386&format=html

BUT converting this into Perl is for another day!

In reply to Re^3: MySQL Query Time DBI by zebedee
in thread MySQL Query Time DBI by KynkoKat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2021-10-20 04:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (78 votes). Check out past polls.

    Notices?