Header And Logo

| The world's most advanced open source database.

Data Structures | Typedefs | Functions

pg_rusage.h File Reference

#include <sys/time.h>
#include "rusagestub.h"
Include dependency graph for pg_rusage.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  PGRUsage


typedef struct PGRUsage PGRUsage


void pg_rusage_init (PGRUsage *ru0)
const char * pg_rusage_show (const PGRUsage *ru0)

Typedef Documentation

typedef struct PGRUsage PGRUsage

Function Documentation

void pg_rusage_init ( PGRUsage ru0  ) 
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;


    if (ru1.tv.tv_usec < ru0->tv.tv_usec)
        ru1.tv.tv_usec += 1000000;
    if (ru1.ru.ru_stime.tv_usec < ru0->ru.ru_stime.tv_usec)
        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_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;