Thanks!  

I will get to this as soon as I can.

-Mike

> -----Original Message-----
> From: Benno Luthiger [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, March 27, 2002 9:31 AM
> To: [EMAIL PROTECTED]
> Subject: [PATCH] Write summary to reporter file
> 
> 
> Hello
> 
> I'm using JMeter and I found it useful having the summary of 
> a test run
> written to the reporter file. Therefore I createt a new class
> FilerSummary.java and included it in the class Filer.java. 
> The information
> written to the reporter file has the following form:
> # Number of requests: 300
> # Average value:      446
> # Deviation:          1,203.807
> # Minimal value:      155
> # Maximal value:      7746
> # Start time of test sequence: 27-Mar-02 12:12:37
> # End time of test sequence:   27-Mar-02 12:18:55
> # Duration of test sequence:   00:06:18 (+ 502 Milliseconds)
> 
> Hope you find it useful too.
> 
> Benno
> 
> 
> Index: Filer.java
> ===================================================================
> RCS file:
> /home/cvspublic/jakarta-jmeter/src/org/apache/jmeter/reporters
> /Filer.java,v
> retrieving revision 1.12
> diff -u -r1.12 Filer.java
> --- Filer.java        4 Mar 2002 23:08:54 -0000       1.12
> +++ Filer.java        27 Mar 2002 12:26:33 -0000
> @@ -84,6 +84,8 @@
>    private boolean open = false;
>    private String file;
>    private PrintWriter stream;
> +
> +  private FilerSummary summary;
> 
>    // if set to true, the file will flush each time a sample 
> is recorded.
>    // required for non-gui testing. Will be added to GUI in a 
> little bit.
> @@ -177,6 +179,7 @@
>               long sample = sampleResult.getTime();
>               String data = 
> (String)sampleResult.getValue(HttpSampleResult.DATA);
>               if (open) {
> +                     summary.addData(sample);
>                 if (verbose) {
>                        
> stream.print(sampleResult.getValue(SampleResult.SAMPLE_LABEL) + " " +
> sample);
>                        if(data != null)
> @@ -200,6 +203,7 @@
>                 else
>                        this.stream.println("\n#       URL     
>                Milliseconds\n");
>               }
> +             summary = new FilerSummary();
>               this.open = true;
>        }catch (Exception ex){
>                 ex.printStackTrace();
> @@ -216,6 +220,7 @@
>    public void close() {
>        try{
>               if(this.open){
> +                     this.stream.println(summary.getSummary());
>                 this.stream.flush();
>                 this.stream.close();
>               }
> @@ -250,4 +255,4 @@
>        this.viewSubmitData = value;
>    }
> 
> -}
> +}
> \ No newline at end of file
> 
> 
> Index: Filer.java
> ===================================================================
> 
> /*
>  * 
> ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2001 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  * notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above 
> copyright
>  * notice, this list of conditions and the following disclaimer in
>  * the documentation and/or other materials provided with the
>  * distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  * if any, must include the following acknowledgment:
>  * "This product includes software developed by the
>  * Apache Software Foundation (http://www.apache.org/)."
>  * Alternately, this acknowledgment may appear in the software itself,
>  * if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  * "Apache JMeter" must not be used to endorse or promote products
>  * derived from this software without prior written permission. For
>  * written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  * "Apache JMeter", nor may "Apache" appear in their name, without
>  * prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * 
> ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> 
> package org.apache.jmeter.reporters;
> 
> import java.text.DateFormat;
> import java.text.NumberFormat;
> import java.text.SimpleDateFormat;
> import java.util.Date;
> import java.util.Enumeration;
> import java.util.Vector;
> 
> /**
>  * This class calculates and holds summary information on a 
> test-sequence.
>  *
>  * The summarized information has the following form:
>  * # Number of requests: 300
>  * # Average value:      446
>  * # Deviation:          1,203.807
>  * # Minimal value:      155
>  * # Maximal value:      7746
>  * # Start time of test sequence: 27-Mar-02 12:12:37
>  * # End time of test sequence:   27-Mar-02 12:18:55
>  * # Duration of test sequence:   00:06:18 (+ 502 Milliseconds)
>  *
>  * @author Benno Luthiger
>  * @version 1.0
>  */
> public class FilerSummary {
>       private Vector data;
>       private long minValue = Integer.MAX_VALUE;
>       private long maxValue = 0;
>       private long sumValue = 0;
>       private Date startTime;
>       private Date endTime;
> 
>       /**
>        * Default constructor
>        */
>       public FilerSummary() {
>               super();
>               data = new Vector();
>       }
>       /**
>        * Gets the summary information
>        *
>        * @return java.lang.String Summary of this test sequence
>        */
>       public String getSummary() {
>               StringBuffer lSummary = new StringBuffer("");
>               int lCount = data.size();
> 
>               lSummary.append("\n# Number of requests: " + lCount);
> 
>               if (lCount > 0) {
>                       double lAverage = sumValue / lCount;
>                       DateFormat dateFormatter = 
> DateFormat.getDateTimeInstance();
>                       NumberFormat numberFormatter = 
> NumberFormat.getNumberInstance();
> 
>                       lSummary.append("\n# Average value:      " +
> numberFormatter.format(lAverage));
>                       lSummary.append("\n# Deviation:          " +
> numberFormatter.format(getDeviation(lAverage, lCount)));
>                       lSummary.append("\n# Minimal value:     
>  " + minValue);
>                       lSummary.append("\n# Maximal value:     
>  " + maxValue);
>                       lSummary.append("\n# Start time of test 
> sequence: " +
> dateFormatter.format(startTime));
>                       lSummary.append("\n# End time of test 
> sequence:   " +
> dateFormatter.format(endTime));
> 
>                       Date lElapsed = new Date(82800000 + 
> endTime.getTime() -
> startTime.getTime());
>                       SimpleDateFormat lTimeFormater = new 
> SimpleDateFormat("HH:mm:ss (+ SSS
> 'Milliseconds')");
>                       lSummary.append("\n# Duration of test 
> sequence:   " +
> lTimeFormater.format(lElapsed));
>               }
>               return new String(lSummary);
>       }
> 
>       /**
>        * Adds a new data point to the summary
>        *
>        * @param long inTime Time used to process the actual request
>        */
>       public void addData(long inTime) {
>               // remember start and end time of test sequence
>               endTime = new Date(System.currentTimeMillis());
>               if (startTime == null) startTime = endTime;
> 
>               // sets min and max value
>               minValue = Math.min(inTime, minValue);
>               maxValue = Math.max(inTime, maxValue);
>               sumValue += inTime;
> 
>               // adds the data to the data vector
>               data.add(new Long(inTime));
>       }
> 
>       /**
>        * Calculates the deviation of the data points
>        *
>        * @param double inAverage The average of the data points.
>        * @param int inCount The number of data points.
>        * @return double The deviation of the data points.
>        */
>       private double getDeviation(double inAverage, int inCount) {
>               double outValue = 0;
>               double lDifference;
> 
>               //pre
>               if (inCount <= 1) return 0;
> 
>               Enumeration lTimeData = data.elements();
>               while (lTimeData.hasMoreElements()) {
>                       lDifference = 
> ((Long)lTimeData.nextElement()).floatValue() - inAverage;
>                       outValue += lDifference * lDifference;
>               }
>               outValue /= (inCount - 1);
>               return Math.sqrt(outValue);
>       }
> 
> }
> 
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

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

Reply via email to