#include <sys/time.h>
#include "rusagestub.h"
Go to the source code of this file.
Data Structures | |
struct | PGRUsage |
Typedefs | |
typedef struct PGRUsage | PGRUsage |
Functions | |
void | pg_rusage_init (PGRUsage *ru0) |
const char * | pg_rusage_show (const PGRUsage *ru0) |
void pg_rusage_init | ( | PGRUsage * | ru0 | ) |
Definition at line 27 of file pg_rusage.c.
References getrusage(), gettimeofday(), NULL, PGRUsage::ru, RUSAGE_SELF, and PGRUsage::tv.
Referenced by copy_heap_data(), do_analyze_rel(), lazy_cleanup_index(), lazy_scan_heap(), lazy_truncate_heap(), lazy_vacuum_heap(), lazy_vacuum_index(), lazy_vacuum_rel(), pg_rusage_show(), and tuplesort_begin_common().
{ getrusage(RUSAGE_SELF, &ru0->ru); gettimeofday(&ru0->tv, NULL); }
const char* pg_rusage_show | ( | const PGRUsage * | ru0 | ) |
Definition at line 40 of file pg_rusage.c.
References pg_rusage_init(), PGRUsage::ru, rusage::ru_stime, rusage::ru_utime, snprintf(), and PGRUsage::tv.
Referenced by copy_heap_data(), do_analyze_rel(), dumptuples(), inittapes(), lazy_cleanup_index(), lazy_scan_heap(), lazy_truncate_heap(), lazy_vacuum_heap(), lazy_vacuum_index(), lazy_vacuum_rel(), mergeonerun(), puttuple_common(), tuplesort_end(), and tuplesort_performsort().
{ static char result[100]; PGRUsage ru1; pg_rusage_init(&ru1); if (ru1.tv.tv_usec < ru0->tv.tv_usec) { ru1.tv.tv_sec--; ru1.tv.tv_usec += 1000000; } if (ru1.ru.ru_stime.tv_usec < ru0->ru.ru_stime.tv_usec) { ru1.ru.ru_stime.tv_sec--; ru1.ru.ru_stime.tv_usec += 1000000; } if (ru1.ru.ru_utime.tv_usec < ru0->ru.ru_utime.tv_usec) { ru1.ru.ru_utime.tv_sec--; ru1.ru.ru_utime.tv_usec += 1000000; } snprintf(result, sizeof(result), "CPU %d.%02ds/%d.%02du sec elapsed %d.%02d sec", (int) (ru1.ru.ru_stime.tv_sec - ru0->ru.ru_stime.tv_sec), (int) (ru1.ru.ru_stime.tv_usec - ru0->ru.ru_stime.tv_usec) / 10000, (int) (ru1.ru.ru_utime.tv_sec - ru0->ru.ru_utime.tv_sec), (int) (ru1.ru.ru_utime.tv_usec - ru0->ru.ru_utime.tv_usec) / 10000, (int) (ru1.tv.tv_sec - ru0->tv.tv_sec), (int) (ru1.tv.tv_usec - ru0->tv.tv_usec) / 10000); return result; }