MCPcopy Create free account
hub / github.com/apache/cloudberry / PrintTiming

Function PrintTiming

src/bin/psql/common.c:480–524  ·  view source on GitHub ↗

* Print microtiming output. Always print raw milliseconds; if the interval * is >= 1 second, also break it down into days/hours/minutes/seconds. */

Source from the content-addressed store, hash-verified

478 * is >= 1 second, also break it down into days/hours/minutes/seconds.
479 */
480static void
481PrintTiming(double elapsed_msec)
482{
483 double seconds;
484 double minutes;
485 double hours;
486 double days;
487
488 if (elapsed_msec < 1000.0)
489 {
490 /* This is the traditional (pre-v10) output format */
491 printf(_("Time: %.3f ms\n"), elapsed_msec);
492 return;
493 }
494
495 /*
496 * Note: we could print just seconds, in a format like %06.3f, when the
497 * total is less than 1min. But that's hard to interpret unless we tack
498 * on "s" or otherwise annotate it. Forcing the display to include
499 * minutes seems like a better solution.
500 */
501 seconds = elapsed_msec / 1000.0;
502 minutes = floor(seconds / 60.0);
503 seconds -= 60.0 * minutes;
504 if (minutes < 60.0)
505 {
506 printf(_("Time: %.3f ms (%02d:%06.3f)\n"),
507 elapsed_msec, (int) minutes, seconds);
508 return;
509 }
510
511 hours = floor(minutes / 60.0);
512 minutes -= 60.0 * hours;
513 if (hours < 24.0)
514 {
515 printf(_("Time: %.3f ms (%02d:%02d:%06.3f)\n"),
516 elapsed_msec, (int) hours, (int) minutes, seconds);
517 return;
518 }
519
520 days = floor(hours / 24.0);
521 hours -= 24.0 * days;
522 printf(_("Time: %.3f ms (%.0f d %02d:%02d:%06.3f)\n"),
523 elapsed_msec, days, (int) hours, (int) minutes, seconds);
524}
525
526
527/*

Callers 2

PSQLexecWatchFunction · 0.85
SendQueryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected