w_rusage.h

00001 /**\cond skip */
00002 /*<std-header orig-src='shore' incl-file-exclusion='W_RUSAGE_H'>
00003 
00004  $Id: w_rusage.h,v 1.15 2010/12/08 17:37:37 nhall Exp $
00005 
00006 SHORE -- Scalable Heterogeneous Object REpository
00007 
00008 Copyright (c) 1994-99 Computer Sciences Department, University of
00009                       Wisconsin -- Madison
00010 All Rights Reserved.
00011 
00012 Permission to use, copy, modify and distribute this software and its
00013 documentation is hereby granted, provided that both the copyright
00014 notice and this permission notice appear in all copies of the
00015 software, derivative works or modified versions, and any portions
00016 thereof, and that both notices appear in supporting documentation.
00017 
00018 THE AUTHORS AND THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY
00019 OF WISCONSIN - MADISON ALLOW FREE USE OF THIS SOFTWARE IN ITS
00020 "AS IS" CONDITION, AND THEY DISCLAIM ANY LIABILITY OF ANY KIND
00021 FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
00022 
00023 This software was developed with support by the Advanced Research
00024 Project Agency, ARPA order number 018 (formerly 8230), monitored by
00025 the U.S. Army Research Laboratory under contract DAAB07-91-C-Q518.
00026 Further funding for this work was provided by DARPA through
00027 Rome Research Laboratory Contract No. F30602-97-2-0247.
00028 
00029 */
00030 
00031 #ifndef W_RUSAGE_H
00032 #define W_RUSAGE_H
00033 
00034 #include "w_defines.h"
00035 
00036 /*  -- do not edit anything above this line --   </std-header>*/
00037 
00038 #include "w_workaround.h"
00039 #include <sys/time.h>
00040 #include <sys/resource.h>
00041 #include <iosfwd>
00042 
00043 /*
00044  * rusage.h
00045  *
00046  * Unix/Solaris rusage stats class.
00047  */
00048 
00049 
00050 class unix_stats {
00051 protected:
00052     struct timeval  time1;        /* gettimeofday() buffer */
00053     struct timeval  time2;        /* gettimeofday() buffer */
00054     struct rusage   rusage1;    /* getrusage() buffer */
00055     struct rusage   rusage2;    /* getrusage() buffer */
00056     void*           sbrk1;        /* sbrk #1 */
00057     void*           sbrk2;        /* sbrk #2 */
00058     int                iterations;
00059 #ifdef Linux
00060 typedef enum __rusage_who who_t;
00061 #else
00062 typedef int who_t;
00063 #endif
00064     who_t who;
00065 
00066 public:
00067     unix_stats();
00068     unix_stats(int who); // if other than self
00069 
00070     float compute_time() const;
00071 
00072     void   start();            /* start gathering stats  */
00073     // you can start and then stop multiple times-- don't need to continue
00074     void   stop(int iter=1);            /* stop gathering stats  */
00075     int    clocktime() const;        /* elapsed real time in micro-seconds */
00076     int    usertime() const;        /* elapsed user time in micro-seconds */
00077     int    systime() const;    /* elapsed system time in micro-seconds */
00078     /* variants */
00079     int    s_clocktime() const;        /* diff of seconds only */
00080     int    s_usertime() const;        
00081     int    s_systime() const;    
00082     int    us_clocktime() const;    /* diff of microseconds only */
00083     int    us_usertime() const;        
00084     int    us_systime() const;    
00085 
00086     int    page_reclaims() const;    /* page reclaims */
00087     int    page_faults() const;    /* page faults */
00088     int    swaps() const;            /* swaps */
00089     int    inblock() const;        /* page-ins */
00090     int    oublock() const;        /* page-outs */
00091     int    xrss() const;            /* shared mem resident-set size */
00092     int    drss() const;            /* unshared data size */
00093     int    srss() const;            /* unsared stack size */
00094     int    vcsw() const;            /* voluntary context swtch */
00095     int    invcsw() const;            /* involuntary context swtch */
00096     int    msgsent() const;            /* socket messages sent */
00097     int    msgrecv() const;            /* socket messages recvd */
00098     int    signals() const;            /* signals dispatched */
00099 
00100     int    mem() const;            /* sbrk diff */
00101 
00102     ostream &print(ostream &) const;
00103 };
00104 
00105 extern ostream& operator<<(ostream&, const unix_stats &s);
00106 float compute_time(const struct timeval *start_time, const struct timeval *end_time);
00107 
00108 /*<std-footer incl-file-exclusion='W_RUSAGE_H'>  -- do not edit anything below this line -- */
00109 #endif          /*</std-footer>*/
00110 /**\endcond skip */

Generated on Mon Jan 2 15:13:57 2012 for Shore Storage Manager by  doxygen 1.4.7