/**
   * Create a statistical sample result from an ordinary sample result.
   *
   * @param res the sample result
   */
  public StatisticalSampleResult(SampleResult res) {
    // Copy data that is shared between samples (i.e. the key items):
    setSampleLabel(res.getSampleLabel());

    setThreadName(res.getThreadName());

    setSuccessful(true); // Assume result is OK
    setSampleCount(0); // because we add the sample count in later
    elapsed = 0;
  }
  public void add(SampleResult res) {
    // Add Sample Counter
    setSampleCount(getSampleCount() + res.getSampleCount());

    setBytes(getBytes() + res.getBytes());

    // Add Error Counter
    if (!res.isSuccessful()) {
      errorCount++;
      this.setSuccessful(false);
    }

    // Set start/end times
    if (getStartTime() == 0) { // Bug 40954 - ensure start time gets started!
      this.setStartTime(res.getStartTime());
    } else {
      this.setStartTime(Math.min(getStartTime(), res.getStartTime()));
    }
    this.setEndTime(Math.max(getEndTime(), res.getEndTime()));

    setLatency(getLatency() + res.getLatency());
    setConnectTime(getConnectTime() + res.getConnectTime());

    elapsed += res.getTime();
  }