Changeset 2487 in Sophya for trunk/SophyaLib/SysTools


Ignore:
Timestamp:
Dec 26, 2003, 12:19:21 PM (22 years ago)
Author:
ansari
Message:

Possibilite de specifier temps process et/ou process fils ds ResourceUsage - Reza 26 Dec 2003

Location:
trunk/SophyaLib/SysTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/SysTools/resusage.cc

    r2322 r2487  
    3636/*!
    3737  Constructor. the \b Update() method is called.
    38 */
    39 ResourceUsage::ResourceUsage()
    40 {
     38  \param pg: Process group RU_Self or RU_Children or RU_All
     39*/
     40ResourceUsage::ResourceUsage(RU_ProcGrp pg)
     41{
     42  procgrp = pg;
    4143  struct rlimit rl;
    4244  getrlimit(RLIMIT_DATA, &rl);
     
    9294{
    9395  struct rusage rsu;
    94   int rc = getrusage(RUSAGE_SELF, &rsu);
     96  int rc;
     97  if ((procgrp == RU_Self) || (procgrp == RU_All))
     98    rc = getrusage(RUSAGE_SELF, &rsu);
     99  else
     100    rc = getrusage(RUSAGE_CHILDREN, &rsu);
     101
    95102  delta_tottm = cur_tottm;
    96103  delta_rss = cur_rss;
    97104  cur_usrtm = s_timeval2msec(rsu.ru_utime);
    98105  cur_systm = s_timeval2msec(rsu.ru_stime);
     106  if (procgrp == RU_All) {
     107    struct rusage rsuch;
     108    rc = getrusage(RUSAGE_CHILDREN, &rsuch);
     109    cur_usrtm += s_timeval2msec(rsuch.ru_utime);
     110    cur_systm += s_timeval2msec(rsuch.ru_stime);   
     111  }
    99112  cur_tottm = cur_usrtm+cur_systm;
    100113  delta_tottm = cur_tottm-delta_tottm;
     
    130143  os << " --------------- ResourceUsage::Print(lp=" << lp
    131144     <<" ) --------------- " << endl;
    132   int load = getAverageCPULoad()*100.;
     145  int load = (int)(getAverageCPULoad()*100.);
    133146  os << " CPU-Usage= " << getCPUTime() << " Elapsed= " << getElapsedTime()
    134147     << " msec - Load= " << load << " %" << endl;
  • trunk/SophyaLib/SysTools/resusage.h

    r2322 r2487  
    1717{
    1818public:
    19   ResourceUsage();
     19  enum RU_ProcGrp {RU_Self=0, RU_Children=1, RU_All=2};
     20  // RU_Self: Resource usage for the process itself
     21  // RU_Children: Resource usage for the child processes
     22  // RU_All: Process itself and child processes
     23  ResourceUsage(RU_ProcGrp pg=RU_Self);
    2024  ~ResourceUsage();
    2125
     
    8589
    8690protected:
     91  RU_ProcGrp procgrp; // Process group: self, child, all
    8792  uint_8 max_datasz;  // Max data segment size (KBytes)
    8893  uint_8 max_rss;     // Max resident size
  • trunk/SophyaLib/SysTools/zthread.cc

    r2212 r2487  
    1717  \sa SOPHYA::ZMutex
    1818  The following sample code shows the usage of ZThread object
    19   to run simultaneously to functions to perform computation.
     19  to run simultaneously two functions to perform computation.
    2020
    2121  \code
Note: See TracChangeset for help on using the changeset viewer.