Yes. It's nothing more than the elapsed time. You can replicate it by storing the start time and subtracting it from the time when the query ends. Like this pseudo-code.
start = Time.now
do_the_query
end = Time.now
elapsed_time = end - start
Digging into the mysql source code, this is nothing more than the elapsed clock time.
Here's the relevant code in client/mysql.cc.
static ulong start_timer(void) {
#if defined(_WIN32)
return clock();
#else
struct tms tms_tmp;
return times(&tms_tmp);
#endif
}
static void end_timer(ulong start_time, char *buff) {
nice_time((double)(start_timer() - start_time) / CLOCKS_PER_SEC, buff, true);
}
static void mysql_end_timer(ulong start_time, char *buff) {
buff[0] = ' ';
buff[1] = '(';
end_timer(start_time, buff + 2);
my_stpcpy(strend(buff), ")");
}
static int com_go(String *buffer, char *line MY_ATTRIBUTE((unused))) {
...
char time_buff[52 + 3 + 1]; /* time max + space&parens + NUL */
...
timer = start_timer();
executing_query = true;
error = mysql_real_query_for_lazy(buffer->ptr(), buffer->length());
...
if (verbose >= 3 || !opt_silent)
mysql_end_timer(timer, time_buff);
else
time_buff[0] = '\0';
If you don't read C...
timer = start_timer(); gets the current time from times.
mysql_real_query_for_lazy runs the query.
mysql_end_timer(timer, time_buff) subtracts the current time from the start time and displays it.