KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > test > internal > performance > eval > AbsoluteBandChecker


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.test.internal.performance.eval;
12
13 import org.eclipse.test.internal.performance.PerformanceTestPlugin;
14 import org.eclipse.test.internal.performance.data.Dim;
15 import org.eclipse.test.internal.performance.data.Scalar;
16
17
18 /**
19  * @since 3.1
20  */

21 public class AbsoluteBandChecker extends AssertChecker {
22
23     private long fLowerBand;
24     private long fUpperBand;
25
26     public AbsoluteBandChecker(Dim dimension, long lowerBand, long upperBand) {
27         super(dimension);
28         fLowerBand= lowerBand;
29         fUpperBand= upperBand;
30     }
31     
32     public boolean test(StatisticsSession reference, StatisticsSession measured, StringBuffer JavaDoc message) {
33         Dim dimension= getDimension();
34
35         if (!measured.contains(dimension)) {
36             PerformanceTestPlugin.logWarning("collected data provides no dimension '"+dimension.getName()+'\''); //$NON-NLS-1$ //$NON-NLS-2$
37
return true;
38         }
39         if (!reference.contains(dimension)) {
40             PerformanceTestPlugin.logWarning("reference data provides no dimension '"+dimension.getName()+'\''); //$NON-NLS-1$ //$NON-NLS-2$
41
return true;
42         }
43         
44         double actual= measured.getAverage(dimension);
45         double test= reference.getAverage(dimension);
46         
47         if (actual > fUpperBand + test || actual < test - fLowerBand) {
48             message.append('\n' + dimension.getName() + ": " + dimension.getDisplayValue(actual) + " is not within [-" + dimension.getDisplayValue(new Scalar(null, fLowerBand)) + ", +" + dimension.getDisplayValue(new Scalar(null, fUpperBand)) + "] of " + dimension.getDisplayValue(test)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
49
return false;
50         }
51         
52         return true;
53     }
54 }
55
Popular Tags