Ejemplo n.º 1
0
 /** {@inheritDoc} */
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = (prime * result) + count;
   result = (prime * result) + TimerRawContainer.hashCode(cpuData);
   result = (prime * result) + TimerRawContainer.hashCode(data);
   return result;
 }
Ejemplo n.º 2
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;
  }
Ejemplo n.º 3
0
 /** Creates a new container if it is necessary. */
 private void createContainerIfNecessary() {
   if (container.isFull()) {
     container = new TimerRawContainer();
     data.add(container);
   }
 }
Ejemplo n.º 4
0
 /**
  * Adds a new time and cpu time value to the current data container.
  *
  * @param time The time value.
  * @param cpuTime The cpu time value.
  */
 public void add(double time, double cpuTime) {
   createContainerIfNecessary();
   container.add(time, cpuTime);
 }