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.io.BufferedOutputStream; 14402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.DataOutputStream; 15402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.File; 16402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.FileNotFoundException; 17402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.FileOutputStream; 18402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.IOException; 19402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.util.Arrays; 20402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.core.runtime.IProgressMonitor; 21402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.results.db.*; 22402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.results.utils.IPerformancesConstants; 23402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.results.utils.Util; 24402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 25402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic class PerformanceResultsElement extends ResultsElement { 26402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 27402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll// Singleton pattern 28402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static PerformanceResultsElement PERF_RESULTS_MODEL = new PerformanceResultsElement(); 29402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 30402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] buildNames; 31402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String lastBuildName; 32402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll boolean fingerprints = true; 33402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 34402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic PerformanceResultsElement() { 35402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll super(); 36402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 37402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 38402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollResultsElement createChild(AbstractResults testResults) { 39402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return new ComponentResultsElement(testResults, this); 40402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 41402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 42402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic String[] getBaselines() { 43402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll getBuildNames(); 44402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.buildNames == null) { 45402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return new String[0]; 46402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 47402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = this.buildNames.length; 48402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] baselines = new String[length]; 49402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int count = 0; 50402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int i=0; i<length; i++) { 51402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.buildNames[i].startsWith("R-")) { 52402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll baselines[count++] = this.buildNames[i]; 53402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 54402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 55402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (count < length) { 56402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.arraycopy(baselines, 0, baselines = new String [count], 0, count); 57402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 58402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return baselines; 59402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 60402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 61402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollString[] getBuildNames() { 62402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.buildNames == null) { 63402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.buildNames = DB_Results.DB_CONNECTION 64402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ? DB_Results.getBuilds() 65402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll : this.results == null 66402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ? new String[0] 67402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll : getPerformanceResults().getAllBuildNames(); 68402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 69402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return this.buildNames; 70402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 71402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 72402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic Object[] getBuilds() { 73402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll getBuildNames(); 74402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = this.buildNames == null ? 0 : this.buildNames.length; 75402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll BuildResultsElement[] elements = new BuildResultsElement[length]; 76402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int i=0; i<length; i++) { 77402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll elements[i] = new BuildResultsElement(this.buildNames[i], this); 78402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 79402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return elements; 80402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 81402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 82402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic String[] getComponents() { 83402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (!isInitialized()) { 84402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] components = DB_Results.getComponents(); 85402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = components.length; 86402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (length == 0) { 87402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_Results.queryAllScenarios(); 88402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll components = DB_Results.getComponents(); 89402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 90402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return components; 91402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 92402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return getPerformanceResults().getComponents(); 93402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 94402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 95402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 96402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Returns the names of the configurations. 97402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 98402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return An array of String 99402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 100402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic String[] getConfigs() { 101402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (!isInitialized()) { 102402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] configs = DB_Results.getConfigs(); 103402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = configs.length; 104402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (length == 0) { 105402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_Results.queryAllScenarios(); 106402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll configs = DB_Results.getConfigs(); 107402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 108402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return configs; 109402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 110402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return getPerformanceResults().getConfigNames(false); 111402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 112402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 113402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 114402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Returns the descriptions of the configurations. 115402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 116402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return An array of String 117402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 118402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic String[] getConfigDescriptions() { 119402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (!isInitialized()) { 120402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] descriptions = DB_Results.getConfigDescriptions(); 121402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = descriptions.length; 122402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (length == 0) { 123402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_Results.queryAllScenarios(); 124402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll descriptions = DB_Results.getConfigDescriptions(); 125402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 126402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return descriptions; 127402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 128402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return getPerformanceResults().getConfigBoxes(false); 129402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 130402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 131402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic Object[] getElements() { 132402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (!isInitialized()) { 133402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] components = getComponents(); 134402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = components.length; 135402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ComponentResultsElement[] elements = new ComponentResultsElement[length]; 136402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int i=0; i<length; i++) { 137402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll elements[i] = new ComponentResultsElement(components[i], this); 138402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 139402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return elements; 140402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 141402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return getChildren(null); 142402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 143402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 144402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic PerformanceResults getPerformanceResults() { 145402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return (PerformanceResults) this.results; 146402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 147402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 148402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollboolean hasRead(BuildResultsElement buildResultsElement) { 149402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] builds = this.results == null ? getBuildNames() : getPerformanceResults().getAllBuildNames(); 150402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (Arrays.binarySearch(builds, buildResultsElement.getName(), Util.BUILD_DATE_COMPARATOR) < 0) { 151402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return false; 152402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 153402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return true; 154402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 155402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 156402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic boolean isInitialized() { 157402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return super.isInitialized() && this.results.size() > 0; 158402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 159402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 160402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic void readLocal(File dataDir, IProgressMonitor monitor, String lastBuild) { 161402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll reset(lastBuild); 162402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll PerformanceResults performanceResults = getPerformanceResults(); 163402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll performanceResults.setLastBuildName(lastBuild); 164402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll performanceResults.readLocal(dataDir, monitor); 165402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 166402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 167402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic void reset(String buildName) { 168402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (buildName == null) { 169402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.results = new PerformanceResults(this.lastBuildName, null, null, System.out); 170402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 171402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.results = new PerformanceResults(buildName, null, null, System.out); 172402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 173402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.children = null; 174402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.buildNames = null; 175402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 176402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 177402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic void resetBuildNames() { 178402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.buildNames = null; 179402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 180402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 181402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic void updateBuild(String buildName, boolean force, File dataDir, IProgressMonitor monitor) { 182402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.results == null) { 183402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll reset(buildName); 184402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 185402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll getPerformanceResults().updateBuild(buildName, force, dataDir, monitor); 186402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 187402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 188402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic void updateBuilds(String[] builds, boolean force, File dataDir, IProgressMonitor monitor) { 189402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.results == null) { 190402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll reset(null); 191402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 192402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll getPerformanceResults().updateBuilds(builds, force, dataDir, monitor); 193402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 194402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 195402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 196402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Set whether only fingerprints should be taken into account or not. 197402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 198402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param fingerprints 199402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 200402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic void setFingerprints(boolean fingerprints) { 201402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.fingerprints = fingerprints; 202402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll resetStatus(); 203402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 204402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 205402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic void setLastBuildName(String lastBuildName) { 206402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.lastBuildName = lastBuildName; 207402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.name = null; 208402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 209402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 210402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* 211402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Write the component status in the given file 212402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 213402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic StringBuffer writeStatus(File resultsFile, int kind) { 214402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.results == null) { 215402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return null; 216402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 217402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll boolean values = (kind & IPerformancesConstants.STATUS_VALUES) != 0; 218402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Write status only for component with error 219402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll StringBuffer excluded = new StringBuffer(); 220402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 221402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DataOutputStream stream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(resultsFile))); 222402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 223402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll StringBuffer buffer = new StringBuffer(); 224402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Print build name 225402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append("Status for "); 226402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(getPerformanceResults().getName()); 227402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(Util.LINE_SEPARATOR); 228402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Print status options 229402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if ((kind & ~IPerformancesConstants.STATUS_VALUES) > 0) { 230402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append("Options: "); 231402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(Util.LINE_SEPARATOR); 232402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll final int errorLevel = kind & IPerformancesConstants.STATUS_ERROR_LEVEL_MASK; 233402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (errorLevel != 0) { 234402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" error level: "); 235402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll switch (errorLevel) { 236402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll case IPerformancesConstants.STATUS_ERROR_NONE: 237402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append("include all failures whatever the error level is"); 238402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll break; 239402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll case IPerformancesConstants.STATUS_ERROR_NOTICEABLE: 240402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append("all failures with at least a noticeable error (> 3%) are excluded!"); 241402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll break; 242402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll case IPerformancesConstants.STATUS_ERROR_SUSPICIOUS: 243402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append("all failures with at least a suspicious error (> 25%) are excluded!"); 244402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll break; 245402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll case IPerformancesConstants.STATUS_ERROR_WEIRD: 246402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append("all failures with at least a weird error (> 50%) are excluded!"); 247402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll break; 248402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll case IPerformancesConstants.STATUS_ERROR_INVALID: 249402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append("all failures with an invalid error (> 100%) are excluded!"); 250402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll break; 251402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 252402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(Util.LINE_SEPARATOR); 253402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 254402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll final int smallValue = kind & IPerformancesConstants.STATUS_SMALL_VALUE_MASK; 255402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (smallValue > 0) { 256402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" small value: "); 257402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll switch (smallValue) { 258402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll case IPerformancesConstants.STATUS_SMALL_VALUE_BUILD: 259402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append("all failures with a small build value (<100ms) are excluded!"); 260402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll break; 261402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll case IPerformancesConstants.STATUS_SMALL_VALUE_DELTA: 262402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append("all failures with a small delta value (<100ms) are excluded!"); 263402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll break; 264402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll case IPerformancesConstants.STATUS_SMALL_VALUE_MASK: 265402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append("all failures with a small build or delta value (<100ms) are excluded!"); 266402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll break; 267402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 268402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(Util.LINE_SEPARATOR); 269402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 270402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll final int stats = kind & IPerformancesConstants.STATUS_STATISTICS_MASK; 271402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (stats > 0) { 272402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" statistics: "); 273402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll switch (stats) { 274402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll case IPerformancesConstants.STATUS_STATISTICS_ERRATIC: 275402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append("all failures with erratic baseline results (variation > 20%) are excluded!"); 276402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll break; 277402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll case IPerformancesConstants.STATUS_STATISTICS_UNSTABLE: 278402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append("all failures with unstable baseline results (10% < variation < 20%) are excluded!"); 279402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll break; 280402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 281402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(Util.LINE_SEPARATOR); 282402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 283402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int buildsNumber = kind & IPerformancesConstants.STATUS_BUILDS_NUMBER_MASK; 284402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" builds to confirm a regression: "); 285402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(buildsNumber); 286402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(Util.LINE_SEPARATOR); 287402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 288402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Print columns title 289402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append("Component"); 290402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" Scenario"); 291402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" Machine"); 292402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (values) { 293402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" Build "); 294402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" History "); 295402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 296402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" Comment"); 297402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(Util.LINE_SEPARATOR); 298402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (values) { 299402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" value"); 300402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" baseline"); 301402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" variation"); 302402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" delta"); 303402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" error"); 304402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" n"); 305402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" mean"); 306402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" deviation"); 307402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" coeff"); 308402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(Util.LINE_SEPARATOR); 309402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 310402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.write(buffer.toString().getBytes()); 311402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll StringBuffer componentBuffer = writableStatus(new StringBuffer(), kind, excluded); 312402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (componentBuffer.length() > 0) { 313402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.write(componentBuffer.toString().getBytes()); 314402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 315402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 316402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll finally { 317402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.close(); 318402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 319402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (FileNotFoundException e) { 320402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.err.println("Can't create output file"+resultsFile); //$NON-NLS-1$ 321402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (IOException e) { 322402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll e.printStackTrace(); 323402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 324402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return excluded; 325402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 326402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 327402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 328