Beispiel #1
0
/* Meter the system load */
void meter_getLoad(meter_sysload_t *load) {
    static int updateDelay = -1;
    if (updateDelay-- >= 0) {
        return;
    }
    updateDelay = MEASURE_LOAD_EVERY;

    measureMemory(load);
    measureCpuLoad(load);

    // Delay IO measurement even more; empirical studies show that this gives us
    // a lot better values.
    static int ioDelay = -1;
    if (ioDelay-- >= 0) {
      return;
    }
    // The magical number 2 comes from a trial-and-error session.  2 looks nice.
    ioDelay = 2;

    measureIoLoad(load);
}
Beispiel #2
0
/* Initialize the load metering */
void meter_init(meter_sysload_t *load) {
#ifdef DEBUG
  dynamic_accumulator_selftest();
#endif
  
  load->user = dynamic_accumulator_create();
  
  measureMemory(load);
  
  load->nCpus = getCpuCount();
  assert(load->nCpus > 0);
  load->cpuLoad = calloc(load->nCpus, sizeof(int));
  
  // Initialize the load histories and indices
  load->cpuAccumulators = calloc(load->nCpus, sizeof(accumulator_t*));
  for (int cpuNo = 0; cpuNo < load->nCpus; cpuNo++) {
    load->cpuAccumulators[cpuNo] = accumulator_create(LOADSAMPLES / MEASURE_LOAD_EVERY);
  }
  
  IOMasterPort(bootstrap_port, &masterPort);
  measureIoLoad(load);
}
Beispiel #3
0
 Elapsed(MeasureProcessMemory measureProcessMemory = kNoMeasureProcessMemory)
     : sec(), wallSec(), deltaBytes() {
   measureMemory(measureProcessMemory);
 }
Beispiel #4
0
 void measureMemory(MeasureProcessMemory measureProcessMemory = kMeasureProcessMemory) {
   measureMemory(measureProcessMemory == kMeasureProcessMemory);
 }
Beispiel #5
0
 /**
    initialize with elapsed time from (already created/started) timer, and
    optionally measure process memory.
 */
 Elapsed(boost::timer::cpu_timer const& timer, MeasureProcessMemory measureProcessMemory,
         double peakBytes = 0, double deltaBytes = 0)
     : peakBytes(peakBytes), deltaBytes(deltaBytes) {
   measureElapsed(timer);
   measureMemory(measureProcessMemory);
 }