Ejemplo n.º 1
0
  /** {@inheritDoc} */
  @Override
  public DefaultData finalizeData() {
    TimerData timerData =
        new TimerData(getTimeStamp(), getPlatformIdent(), getSensorTypeIdent(), getMethodIdent());
    timerData.setParameterContentData(getParameterContentData());
    timerData.setCharting(charting);

    double[] values;
    double value;

    double min = Double.MAX_VALUE;
    double max = 0.0d;
    int count = 0;
    double duration = 0.0d;

    double cpuMin = Double.MAX_VALUE;
    double cpuMax = 0.0d;
    double cpuDuration = 0.0d;

    for (TimerRawContainer container : data) {
      values = container.getData();
      for (int j = 0; j < container.getCount(); j++) {
        value = values[j];
        duration += value;
        if (value < min) {
          min = value;
        }
        if (value > max) {
          max = value;
        }
      }
      count += container.getCount();

      values = container.getCpuData();
      if (null != values) {
        for (int j = 0; j < container.getCount(); j++) {
          value = values[j];
          cpuDuration += value;
          if (value < cpuMin) {
            cpuMin = value;
          }
          if (value > cpuMax) {
            cpuMax = value;
          }
        }
      }
    }

    timerData.calculateMin(min);
    timerData.calculateMax(max);
    timerData.setCount(count);
    timerData.setDuration(duration);
    // TODO compute the variance
    timerData.setVariance(-1);

    if (Double.MAX_VALUE != cpuMin) {
      timerData.calculateCpuMin(cpuMin);
      timerData.calculateCpuMax(cpuMax);
      timerData.setCpuDuration(cpuDuration);
    }

    return timerData;
  }