1402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/*******************************************************************************
2402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Copyright (c) 2000, 2009 IBM Corporation and others.
3402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * All rights reserved. This program and the accompanying materials
4402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * are made available under the terms of the Eclipse Public License v1.0
5402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * which accompanies this distribution, and is available at
6402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * http://www.eclipse.org/legal/epl-v10.html
7402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
8402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Contributors:
9402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *     IBM Corporation - initial API and implementation
10402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *******************************************************************************/
11402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpackage org.eclipse.test.internal.performance.results.model;
12402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
13402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.util.Vector;
14402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
15402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.ui.views.properties.IPropertyDescriptor;
16402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.ui.views.properties.TextPropertyDescriptor;
17402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
18402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic class BuildResultsProperties {
19402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
20402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	    // Property descriptors
21402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static final String P_ID_SMALL_VALUE = "BuildResultsProperties.small_value"; //$NON-NLS-1$
22402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static final String P_ID_NO_BASELINE = "BuildResultsProperties.no_baseline"; //$NON-NLS-1$
23402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static final String P_ID_SINGLE_RUN = "BuildResultsProperties.single_run"; //$NON-NLS-1$
24402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static final String P_ID_BIG_ERROR = "BuildResultsProperties.big_error"; //$NON-NLS-1$
25402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static final String P_ID_STUDENT_TTEST = "BuildResultsProperties.ttest"; //$NON-NLS-1$
26402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static final String P_ID_NOT_STABLE = "BuildResultsProperties.not_stable"; //$NON-NLS-1$
27402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static final String P_ID_NOT_RELIABLE = "BuildResultsProperties.not_reliable"; //$NON-NLS-1$
28402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static final String P_ID_BIG_DELTA = "BuildResultsProperties.big_delta"; //$NON-NLS-1$
29402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static final String P_STR_SMALL_VALUE = "small value"; //$NON-NLS-1$
30402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static final String P_STR_NO_BASELINE = "no baseline"; //$NON-NLS-1$
31402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static final String P_STR_SINGLE_RUN = "single run"; //$NON-NLS-1$
32402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static final String P_STR_BIG_ERROR = "big error"; //$NON-NLS-1$
33402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static final String P_STR_STUDENT_TTEST = "student ttest"; //$NON-NLS-1$
34402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static final String P_STR_NOT_STABLE = "not stable"; //$NON-NLS-1$
35402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static final String P_STR_NOT_RELIABLE = "not reliable"; //$NON-NLS-1$
36402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static final String P_STR_BIG_DELTA = "delta error"; //$NON-NLS-1$
37402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    private static Vector descriptors;
38402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static {
39402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        descriptors = new Vector();
40402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        descriptors.addElement(new TextPropertyDescriptor(P_ID_SMALL_VALUE, P_STR_SMALL_VALUE));
41402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        descriptors.addElement(new TextPropertyDescriptor(P_ID_NO_BASELINE, P_STR_NO_BASELINE));
42402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        descriptors.addElement(new TextPropertyDescriptor(P_ID_SINGLE_RUN, P_STR_SINGLE_RUN));
43402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        descriptors.addElement(new TextPropertyDescriptor(P_ID_BIG_ERROR, P_STR_BIG_ERROR));
44402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        descriptors.addElement(new TextPropertyDescriptor(P_ID_STUDENT_TTEST, P_STR_STUDENT_TTEST));
45402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        descriptors.addElement(new TextPropertyDescriptor(P_ID_NOT_STABLE, P_STR_NOT_STABLE));
46402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        descriptors.addElement(new TextPropertyDescriptor(P_ID_NOT_RELIABLE, P_STR_NOT_RELIABLE));
47402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        descriptors.addElement(new TextPropertyDescriptor(P_ID_BIG_DELTA, P_STR_BIG_DELTA));
48402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
49402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    static Vector getDescriptors() {
50402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        return descriptors;
51402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
52402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
53402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    private int status;
54402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
55402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic BuildResultsProperties() {
56402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
57402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
58402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollvoid setStatus(int status) {
59402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.status = status;
60402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
61402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
62402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic Object getEditableValue() {
63402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	return null;
64402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
65402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
66402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* (non-Javadoc)
67402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
68402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
69402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic IPropertyDescriptor[] getPropertyDescriptors() {
70402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    return (IPropertyDescriptor[]) getDescriptors().toArray(
71402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll            new IPropertyDescriptor[getDescriptors().size()]);
72402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
73402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
74402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* (non-Javadoc)
75402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
76402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
77402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic Object getPropertyValue(Object propKey) {
78402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (propKey.equals(P_ID_SMALL_VALUE)) {
79402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if ((this.status & ResultsElement.SMALL_VALUE) != 0) {
80402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			return "This test and/or its variation has a small value, hence it may not be necessary to spend time on fixing it if a regression occurs.";
81402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
82402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
83402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (propKey.equals(P_ID_NO_BASELINE)) {
84402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if ((this.status & ResultsElement.NO_BASELINE) != 0) {
85402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			return "There's no baseline to compare with.";
86402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
87402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
88402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (propKey.equals(P_ID_SINGLE_RUN)) {
89402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if ((this.status & ResultsElement.SINGLE_RUN) != 0) {
90402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			return "This test has only one run, hence no error can be computed to verify if it's stable enough to be reliable.";
91402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
92402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
93402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (propKey.equals(P_ID_BIG_ERROR)) {
94402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if ((this.status & ResultsElement.BIG_ERROR) != 0) {
95402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			return "The error on this test is over the 3% threshold, hence its result may not be really reliable.";
96402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
97402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
98402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (propKey.equals(P_ID_STUDENT_TTEST)) {
99402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if ((this.status & ResultsElement.STUDENT_TTEST) != 0) {
100402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			return "The student-t on this test is over the threshold";
101402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
102402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
103402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (propKey.equals(P_ID_NOT_STABLE)) {
104402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if ((this.status & ResultsElement.NOT_STABLE) != 0) {
105402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			return "The results history shows that the variation of its delta is between 10% and 20%, hence its result may not be really reliable.";
106402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
107402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
108402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (propKey.equals(P_ID_NOT_RELIABLE)) {
109402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if ((this.status & ResultsElement.NOT_RELIABLE) != 0) {
110402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			return "The results history shows that the variation of its delta is over 20%, hence its result is surely not reliable.";
111402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
112402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
113402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (propKey.equals(P_ID_BIG_DELTA)) {
114402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if ((this.status & ResultsElement.BIG_DELTA) != 0) {
115402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			return "The delta on this test is over the 10% threshold, hence may indicate a possible regression.";
116402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
117402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
118402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	return null;
119402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
120402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
121402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
122