sebb        2003/12/19 17:00:54

  Modified:    src/core/org/apache/jmeter/samplers SampleResult.java
  Log:
  Removed setTime/setTimeStamp
  Added code to set timeStamp to start of sample if property is set
  Added getters for start/end time
  
  Revision  Changes    Path
  1.22      +30 -23    
jakarta-jmeter/src/core/org/apache/jmeter/samplers/SampleResult.java
  
  Index: SampleResult.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/samplers/SampleResult.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- SampleResult.java 19 Dec 2003 17:53:40 -0000      1.21
  +++ SampleResult.java 20 Dec 2003 01:00:54 -0000      1.22
  @@ -65,6 +65,7 @@
   
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.jmeter.assertions.AssertionResult;
  +import org.apache.jmeter.util.JMeterUtils;
   import org.apache.jorphan.logging.LoggingManager;
   import org.apache.log.LogTarget;
   import org.apache.log.Logger;
  @@ -109,7 +110,7 @@
       private String responseHeaders=""; // Never return null
       private String contentType;
       private String requestHeaders="";
  -    private long timeStamp = 0;// currently the end time stamp
  +    private long timeStamp = 0;// the time stamp - can be start or end
       private long startTime = 0;
       private long endTime = 0;
       private long idleTime = 0;// Allow for non-sample time
  @@ -128,6 +129,9 @@
   
       transient private static Logger log = LoggingManager.getLoggerForClass();
   
  +    private final boolean startTimeStamp = 
  +        JMeterUtils.getPropDefault("sampleresult.timestamp.start",false);
  +
       public SampleResult()
       {
        time = 0;
  @@ -146,7 +150,7 @@
        }
       
       /**
  -     * Allow users to create a sample with specific start and elapsed times
  +     * Allow users to create a sample with specific timestamp and elapsed times
        * for cloning and test purposes, but don't allow the times to be
        * changed later
        * 
  @@ -208,17 +212,6 @@
           return timeStamp;
       }
       
  -    /**
  -     * @deprecated use sampleStart/sampleEnd instead
  -     * 
  -     * @param timeStamp
  -     */
  -
  -    public void setTimeStamp(long timeStamp)
  -    {
  -        this.timeStamp = timeStamp;
  -    }
  -
       public String getSampleLabel()
       {
           return label;
  @@ -284,15 +277,6 @@
       }
   
       /**
  -     * Set the time this sample took to occur.
  -     * @deprecated to be removed - use sampleStart() and sampleEnd() instead
  -     */
  -    public void setTime(long t)
  -    {
  -        time = t;
  -    }
  -
  -    /**
        * Sets the responseData attribute of the SampleResult object.
        *
        * @param  response  the new responseData value
  @@ -482,6 +466,22 @@
           contentType = string;
       }
   
  +     /**
  +      * @return the end time
  +      */
  +     public long getEndTime()
  +     {
  +             return endTime;
  +     }
  +
  +     /**
  +      * @return the start time
  +      */
  +     public long getStartTime()
  +     {
  +             return startTime;
  +     }
  +
       /**
        * Record the start time of a sample
        *
  @@ -490,6 +490,9 @@
       {
        if (startTime == 0){
                        startTime = System.currentTimeMillis();
  +                     if (startTimeStamp){
  +                             timeStamp = startTime;
  +                     }
        } else {
                        log.error("sampleStart called twice", new Throwable("Invalid 
call sequence"));
        }
  @@ -504,6 +507,10 @@
        if (endTime == 0){
                        endTime = System.currentTimeMillis();
                        time = endTime - startTime - idleTime;
  +                     if (!startTimeStamp){
  +                             timeStamp = endTime;
  +                     }
  +
        } else {
                log.error("sampleEnd called twice", new Throwable("Invalid call 
sequence"));
        }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to