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.performance.ui; 12402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 13402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.BufferedOutputStream; 14402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.File; 15402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.FileNotFoundException; 16402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.FileOutputStream; 17402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.PrintStream; 18402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.text.SimpleDateFormat; 19402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.util.ArrayList; 20402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.util.Arrays; 21402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.util.Date; 22402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.util.List; 23402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.util.StringTokenizer; 24402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 25402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.core.runtime.IProgressMonitor; 26402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.core.runtime.IStatus; 27402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.core.runtime.OperationCanceledException; 28402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.core.runtime.Status; 29402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.core.runtime.SubMonitor; 30402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.widgets.Display; 31402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.results.db.ConfigResults; 32402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.results.db.DB_Results; 33402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.results.db.PerformanceResults; 34402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.results.db.ScenarioResults; 35402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.results.utils.Util; 36402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.osgi.framework.Bundle; 37402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 38402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 39402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Main class to generate performance results of all scenarios matching a given pattern 40402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * in one HTML page per component. 41402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 42402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @see #printUsage() method to see a detailed parameters usage 43402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 44402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic class GenerateResults { 45402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 46402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 47402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Prefix of baseline builds displayed in data graphs. 48402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * This field is set using <b>-baseline.prefix</b> argument. 49402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <p> 50402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Example: 51402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <pre>-baseline.prefix 3.2_200606291905</pre> 52402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 53402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @see #currentBuildPrefixes 54402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 55402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollString baselinePrefix = null; 56402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 57402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 58402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Root directory where all files are generated. 59402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * This field is set using <b>-output</b> argument. 60402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <p> 61402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Example: 62402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <pre>-output /releng/results/I20070615-1200/performance</pre> 63402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 64402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollFile outputDir; 65402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 66402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 67402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Root directory where all data are locally stored to speed-up generation. 68402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * This field is set using <b>-dataDir</b> argument. 69402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <p> 70402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Example: 71402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <pre>-dataDir /tmp</pre> 72402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 73402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollFile dataDir; 74402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 75402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 76402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Arrays of 2 strings which contains config information: name and description. 77402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * This field is set using <b>-config</b> and/or <b>-config.properties</b> arguments. 78402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <p> 79402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Example: 80402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <pre> 81402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * -config eclipseperflnx3_R3.3,eclipseperfwin2_R3.3,eclipseperflnx2_R3.3,eclipseperfwin1_R3.3,eclipseperflnx1_R3.3 82402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * -config.properties 83402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * "eclipseperfwin1_R3.3,Win XP Sun 1.4.2_08 (2 GHz 512 MB); 84402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * eclipseperflnx1_R3.3,RHEL 3.0 Sun 1.4.2_08 (2 GHz 512 MB); 85402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * eclipseperfwin2_R3.3,Win XP Sun 1.4.2_08 (3 GHz 2 GB); 86402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * eclipseperflnx2_R3.3,RHEL 3.0 Sun 1.4.2_08 (3 GHz 2 GB); 87402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * eclipseperflnx3_R3.3,RHEL 4.0 Sun 1.4.2_08 (3 GHz 2.5 GB)" 88402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * </pre> 89402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Note that: 90402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <ul> 91402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <li>if only <b>-config</b> is set, then configuration name is used for description </li> 92402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <li>if only <b>-config.properties</b> is set, then all configurations defined with this argument are generated 93402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <li>if both arguments are defined, then only configurations defined by <b>-config</b> argument are generated, 94402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <b>-config.properties</b> argument is only used to set the configuration description.</li> 95402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * </ul> 96402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 97402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollString[][] configDescriptors; 98402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 99402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 100402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Scenario pattern used to generate performance results. 101402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * This field is set using <b>-scenarioPattern</b> argument. 102402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <p> 103402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Note that this pattern uses SQL conventions, not RegEx ones, 104402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * which means that '%' is used to match several consecutive characters 105402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * and '_' to match a single character. 106402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <p> 107402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Example: 108402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <pre>-scenario.pattern org.eclipse.%.test</pre> 109402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 110402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollString scenarioPattern; 111402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 112402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 113402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * A list of prefixes for builds displayed in data graphs. 114402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * This field is set using <b>-currentPrefix</b> argument. 115402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <p> 116402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Example: 117402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <pre>-current.prefix N, I</pre> 118402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 119402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @see #baselinePrefix 120402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 121402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollList currentBuildPrefixes; 122402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 123402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 124402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * A list of prefixes of builds to highlight in displayed data graphs. 125402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * This field is set using <b>-highlight</b> and/or <b>-highlight.latest</b> arguments. 126402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <p> 127402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Example: 128402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <pre>-higlight 3_2</pre> 129402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 130402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollList pointsOfInterest; 131402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 132402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 133402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Tells whether only fingerprints has to be generated. 134402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * This field is set to <code>true</code> if <b>-fingerprints</b> argument is specified. 135402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <p> 136402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Default is <code>false</code> which means that scenario data 137402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * will also be generated. 138402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 139402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @see #genData 140402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @see #genAll 141402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 142402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollboolean genFingerPrints = false; 143402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 144402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 145402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Tells whether only fingerprints has to be generated. 146402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * This field is set to <code>true</code> if <b>-data</b> argument is specified. 147402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <p> 148402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Default is <code>false</code> which means that fingerprints 149402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * will also be generated. 150402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 151402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @see #genFingerPrints 152402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @see #genAll 153402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 154402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollboolean genData = false; 155402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 156402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 157402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Tells whether only fingerprints has to be generated. 158402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * This field is set to <code>false</code> 159402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * if <b>-fingerprints</b> or <b>-data</b> argument is specified. 160402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <p> 161402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Default is <code>true</code> which means that scenario data 162402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * will also be generated. 163402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 164402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @see #genData 165402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @see #genFingerPrints 166402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 167402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollboolean genAll = true; 168402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 169402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 170402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Tells whether information should be displayed in the console while generating. 171402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * This field is set to <code>true</code> if <b>-print</b> argument is specified. 172402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <p> 173402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Default is <code>false</code> which means that nothing is print during the generation. 174402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 175402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollPrintStream printStream = null; 176402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 177402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 178402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Tells what should be the failure percentage threshold. 179402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <p> 180402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Default is 10%. 181402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 182402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollint failure_threshold = 10; // PerformanceTestPlugin.getDBLocation().startsWith("net://"); 183402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 184402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollPerformanceResults performanceResults; 185402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 186402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic GenerateResults() { 187402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 188402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 189402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic GenerateResults(PerformanceResults results, String current, String baseline, boolean fingerprints, File data, File output) { 190402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.dataDir = data; 191402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.outputDir = output; 192402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.genFingerPrints = fingerprints; 193402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.genAll = !fingerprints; 194402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.performanceResults = results; 195402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.printStream = System.out; 196402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll setDefaults(current, baseline); 197402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 198402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 199402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* 200402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Parse the command arguments and create corresponding performance 201402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * results object. 202402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 203402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void parse(String[] args) { 204402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll StringBuffer buffer = new StringBuffer("Parameters used to generate performance results ("); 205402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(new SimpleDateFormat().format(new Date(System.currentTimeMillis()))); 206402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append("):\n"); 207402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int i = 0; 208402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int argsLength = args.length; 209402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (argsLength == 0) { 210402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printUsage(); 211402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 212402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 213402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String currentBuildId = null; 214402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String baseline = null; 215402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String jvm = null; 216402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.configDescriptors = null; 217402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 218402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll while (i < argsLength) { 219402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String arg = args[i]; 220402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (!arg.startsWith("-")) { 221402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll i++; 222402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll continue; 223402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 224402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (argsLength == i + 1 && i != argsLength - 1) { 225402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println("Missing value for last parameter"); 226402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printUsage(); 227402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 228402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (arg.equals("-baseline")) { 229402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll baseline = args[i + 1]; 230402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (baseline.startsWith("-")) { 231402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println("Missing value for "+arg+" parameter"); 232402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printUsage(); 233402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 234402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" -baseline = "+baseline+'\n'); 235402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll i++; 236402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll continue; 237402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 238402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (arg.equals("-baseline.prefix")) { 239402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.baselinePrefix = args[i + 1]; 240402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.baselinePrefix.startsWith("-")) { 241402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println("Missing value for "+arg+" parameter"); 242402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printUsage(); 243402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 244402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" ").append(arg).append(" = ").append(this.baselinePrefix).append('\n'); 245402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll i++; 246402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll continue; 247402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 248402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (arg.equals("-current.prefix")) { 249402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String idPrefixList = args[i + 1]; 250402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (idPrefixList.startsWith("-")) { 251402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println("Missing value for "+arg+" parameter"); 252402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printUsage(); 253402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 254402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" ").append(arg).append(" = "); 255402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] ids = idPrefixList.split(","); 256402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.currentBuildPrefixes = new ArrayList(); 257402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int j = 0; j < ids.length; j++) { 258402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.currentBuildPrefixes.add(ids[j]); 259402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(ids[j]); 260402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 261402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append('\n'); 262402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll i++; 263402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll continue; 264402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 265402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (arg.equals("-highlight") || arg.equals("-highlight.latest")) { 266402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (args[i + 1].startsWith("-")) { 267402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println("Missing value for "+arg+" parameter"); 268402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printUsage(); 269402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 270402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" ").append(arg).append(" = "); 271402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] ids = args[i + 1].split(","); 272402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.pointsOfInterest = new ArrayList(); 273402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int j = 0; j < ids.length; j++) { 274402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.pointsOfInterest.add(ids[j]); 275402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(ids[j]); 276402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 277402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append('\n'); 278402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll i++; 279402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll continue; 280402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 281402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (arg.equals("-current")) { 282402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll currentBuildId = args[i + 1]; 283402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (currentBuildId.startsWith("-")) { 284402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println("Missing value for "+arg+" parameter"); 285402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printUsage(); 286402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 287402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" ").append(arg).append(" = ").append(currentBuildId).append('\n'); 288402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll i++; 289402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll continue; 290402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 291402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (arg.equals("-jvm")) { 292402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll jvm = args[i + 1]; 293402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (jvm.startsWith("-")) { 294402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println("Missing value for "+arg+" parameter"); 295402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printUsage(); 296402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 297402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" ").append(arg).append(" = ").append(jvm).append('\n'); 298402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll i++; 299402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll continue; 300402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 301402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (arg.equals("-output")) { 302402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String dir = args[++i]; 303402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (dir.startsWith("-")) { 304402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println("Missing value for "+arg+" parameter"); 305402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printUsage(); 306402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 307402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.outputDir = new File(dir); 308402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (!this.outputDir.exists() && !this.outputDir.mkdirs()) { 309402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.err.println("Cannot create directory "+dir+" to write results in!"); 310402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.exit(2); 311402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 312402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" ").append(arg).append(" = ").append(dir).append('\n'); 313402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll continue; 314402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 315402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (arg.equals("-dataDir")) { 316402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String dir = args[++i]; 317402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (dir.startsWith("-")) { 318402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println("Missing value for "+arg+" parameter"); 319402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printUsage(); 320402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 321402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.dataDir = new File(dir); 322402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (!this.dataDir.exists() && !this.dataDir.mkdirs()) { 323402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.err.println("Cannot create directory "+dir+" to save data locally!"); 324402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.exit(2); 325402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 326402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" ").append(arg).append(" = ").append(dir).append('\n'); 327402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll continue; 328402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 329402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (arg.equals("-config")) { 330402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String configs = args[i + 1]; 331402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (configs.startsWith("-")) { 332402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println("Missing value for "+arg+" parameter"); 333402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printUsage(); 334402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 335402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] names = configs.split(","); 336402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = names.length; 337402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" ").append(arg).append(" = "); 338402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int j=0; j<length; j++) { 339402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (j>0) buffer.append(','); 340402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(names[j]); 341402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 342402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.configDescriptors == null) { 343402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.configDescriptors = new String[length][2]; 344402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int j=0; j<length; j++) { 345402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.configDescriptors[j][0] = names[j]; 346402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.configDescriptors[j][1] = names[j]; 347402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 348402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 349402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int confLength = this.configDescriptors[0].length; 350402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int newLength = confLength; 351402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll mainLoop: for (int j=0; j<confLength; j++) { 352402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int k=0; k<length; k++) { 353402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.configDescriptors[j][0].equals(names[k])) { 354402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll continue mainLoop; 355402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 356402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 357402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.configDescriptors[j][0] = null; 358402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.configDescriptors[j][1] = null; 359402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll newLength--; 360402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 361402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (newLength < confLength) { 362402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[][] newDescriptors = new String[newLength][2]; 363402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int j=0, c=0; j<newLength; j++) { 364402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.configDescriptors[c] != null) { 365402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll newDescriptors[j][0] = this.configDescriptors[c][0]; 366402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll newDescriptors[j][1] = this.configDescriptors[c][1]; 367402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 368402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll c++; 369402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 370402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 371402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.configDescriptors = newDescriptors; 372402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 373402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 374402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append('\n'); 375402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll i++; 376402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll continue; 377402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 378402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (arg.equals("-config.properties")) { 379402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String configProperties = args[i + 1]; 380402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (configProperties.startsWith("-")) { 381402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println("Missing value for "+arg+" parameter"); 382402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printUsage(); 383402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 384402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.configDescriptors == null) { 385402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println("Missing -config parameter"); 386402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printUsage(); 387402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 388402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = this.configDescriptors.length; 389402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll StringTokenizer tokenizer = new StringTokenizer(configProperties, ";"); 390402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append('\t').append(arg).append(" = '").append(configProperties).append("' splitted in ").append(length).append(" configs:"); 391402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll while (tokenizer.hasMoreTokens()) { 392402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String labelDescriptor = tokenizer.nextToken(); 393402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] elements = labelDescriptor.trim().split(","); 394402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int j=0; j<length; j++) { 395402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (elements[0].equals(this.configDescriptors[j][0])) { 396402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.configDescriptors[j][1] = elements[1]; 397402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append("\n\t\t+ "); 398402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(elements[0]); 399402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" -> "); 400402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(elements[1]); 401402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 402402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 403402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 404402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append('\n'); 405402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll i++; 406402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll continue; 407402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 408402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (arg.equals("-scenario.filter") || arg.equals("-scenario.pattern")) { 409402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.scenarioPattern= args[i + 1]; 410402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.scenarioPattern.startsWith("-")) { 411402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println("Missing value for "+arg+" parameter"); 412402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printUsage(); 413402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 414402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" ").append(arg).append(" = ").append(this.scenarioPattern).append('\n'); 415402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll i++; 416402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll continue; 417402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 418402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (arg.equals("-fingerprints")) { 419402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.genFingerPrints = true; 420402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.genAll = false; 421402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" ").append(arg).append('\n'); 422402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll i++; 423402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll continue; 424402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 425402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (arg.equals("-data")) { 426402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.genData = true; 427402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.genAll = false; 428402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" ").append(arg).append('\n'); 429402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll i++; 430402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll continue; 431402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 432402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (arg.equals("-print")) { 433402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.printStream = System.out; // default is to print to console 434402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" ").append(arg); 435402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll i++; 436402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String printFile = i==argsLength ? null : args[i]; 437402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (printFile==null ||printFile.startsWith("-")) { 438402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" (to the console)").append('\n'); 439402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 440402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 441402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.printStream = new PrintStream(new BufferedOutputStream(new FileOutputStream(printFile))); 442402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 443402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll catch (FileNotFoundException fnfe) { 444402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // use the console if the output file cannot be created 445402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 446402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" (to file: ").append(printFile).append(")\n"); 447402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 448402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll continue; 449402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 450402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (arg.equals("-failure.threshold")) { 451402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String value = args[i + 1]; 452402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 453402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.failure_threshold = Integer.parseInt(value); 454402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.failure_threshold < 0) { 455402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println("Value for "+arg+" parameter must be positive."); 456402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printUsage(); 457402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 458402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 459402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll catch (NumberFormatException nfe) { 460402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println("Invalid value for "+arg+" parameter"); 461402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printUsage(); 462402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 463402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(" ").append(arg).append(" = ").append(value).append('\n'); 464402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll i++; 465402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll continue; 466402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 467402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll i++; 468402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 469402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.printStream != null) { 470402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.printStream.print(buffer.toString()); 471402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 472402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 473402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Stop if some mandatory parameters are missing 474402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.outputDir == null || this.configDescriptors == null || jvm == null) { 475402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printUsage(); 476402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 477402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 478402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Set performance results 479402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll setPerformanceResults(currentBuildId, baseline); 480402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 481402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 482402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* 483402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Print component PHP file 484402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 485402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void printComponent(/*PerformanceResults performanceResults, */String component) throws FileNotFoundException { 486402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.printStream != null) this.printStream.print("."); 487402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll File outputFile = new File(this.outputDir, component + ".php"); 488402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll PrintStream stream = new PrintStream(new BufferedOutputStream(new FileOutputStream(outputFile))); 489402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 490402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Print header 491402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll boolean isGlobal = component.startsWith("global"); 492402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (isGlobal) { 493402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll File globalFile = new File(this.outputDir, "global.php"); 494402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll PrintStream gStream = new PrintStream(new BufferedOutputStream(new FileOutputStream(globalFile))); 495402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print(Utils.HTML_OPEN); 496402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("</head>\n"); 497402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<body>\n"); 498402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<?php\n"); 499402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print(" include(\"global_fp.php\");\n"); 500402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("?>\n"); 501402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<table border=0 cellpadding=2 cellspacing=5 width=\"100%\">\n"); 502402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<tbody><tr> <td colspan=3 align=\"left\" bgcolor=\"#0080c0\" valign=\"top\"><b><font color=\"#ffffff\" face=\"Arial,Helvetica\">\n"); 503402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("Detailed performance data grouped by scenario prefix</font></b></td></tr></tbody></table>\n"); 504402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<a href=\"org.eclipse.ant.php?\">org.eclipse.ant*</a><br>\n"); 505402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<a href=\"org.eclipse.compare.php?\">org.eclipse.compare*</a><br>\n"); 506402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<a href=\"org.eclipse.core.php?\">org.eclipse.core*</a><br>\n"); 507402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<a href=\"org.eclipse.jdt.core.php?\">org.eclipse.jdt.core*</a><br>\n"); 508402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<a href=\"org.eclipse.jdt.debug.php?\">org.eclipse.jdt.debug*</a><br>\n"); 509402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<a href=\"org.eclipse.jdt.text.php?\">org.eclipse.jdt.text*</a><br>\n"); 510402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<a href=\"org.eclipse.jdt.ui.php?\">org.eclipse.jdt.ui*</a><br>\n"); 511402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<a href=\"org.eclipse.jface.php?\">org.eclipse.jface*</a><br>\n"); 512402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<a href=\"org.eclipse.osgi.php?\">org.eclipse.osgi*</a><br>\n"); 513402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<a href=\"org.eclipse.pde.api.tools.php?\">org.eclipse.pde.api.tools*</a><br>\n"); 514402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<a href=\"org.eclipse.pde.ui.php?\">org.eclipse.pde.ui*</a><br>\n"); 515402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<a href=\"org.eclipse.swt.php?\">org.eclipse.swt*</a><br>\n"); 516402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<a href=\"org.eclipse.team.php?\">org.eclipse.team*</a><br>\n"); 517402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<a href=\"org.eclipse.ua.php?\">org.eclipse.ua*</a><br>\n"); 518402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("<a href=\"org.eclipse.ui.php?\">org.eclipse.ui*</a><br><p><br><br>\n"); 519402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print("</body>\n"); 520402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.print(Utils.HTML_CLOSE); 521402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll gStream.close(); 522402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 523402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(Utils.HTML_OPEN); 524402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 525402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<link href=\""+Utils.TOOLTIP_STYLE+"\" rel=\"stylesheet\" type=\"text/css\">\n"); 526402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<script src=\""+Utils.TOOLTIP_SCRIPT+"\"></script>\n"); 527402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<script src=\""+Utils.FINGERPRINT_SCRIPT+"\"></script>\n"); 528402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(Utils.HTML_DEFAULT_CSS); 529402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 530402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Print title 531402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<body>"); 532402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printComponentTitle(/*performanceResults, */component, isGlobal, stream); 533402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 534402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // print the html representation of fingerprint for each config 535402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Display display = Display.getDefault(); 536402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.genFingerPrints || this.genAll) { 537402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll final FingerPrint fingerprint = new FingerPrint(component, stream, this.outputDir); 538402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll display.syncExec( 539402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll new Runnable() { 540402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public void run(){ 541402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 542402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll fingerprint.print(GenerateResults.this.performanceResults); 543402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (Exception ex) { 544402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ex.printStackTrace(); 545402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 546402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 547402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 548402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ); 549402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 550402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll// FingerPrint fingerprint = new FingerPrint(component, stream, this.outputDir); 551402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll// fingerprint.print(performanceResults); 552402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 553402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // print scenario status table 554402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (!isGlobal) { 555402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // print the component scenario status table beneath the fingerprint 556402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll final ScenarioStatusTable sst = new ScenarioStatusTable(component, stream); 557402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll display.syncExec( 558402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll new Runnable() { 559402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public void run(){ 560402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 561402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll sst.print(GenerateResults.this.performanceResults); 562402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (Exception ex) { 563402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ex.printStackTrace(); 564402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 565402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 566402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 567402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ); 568402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll// ScenarioStatusTable sst = new ScenarioStatusTable(component, stream); 569402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll// sst.print(performanceResults); 570402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 571402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 572402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(Utils.HTML_CLOSE); 573402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.close(); 574402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 575402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 576402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void printComponentTitle(/*PerformanceResults performanceResults, */String component, boolean isGlobal, PrintStream stream) { 577402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String baselineName = this.performanceResults.getBaselineName(); 578402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String currentName = this.performanceResults.getName(); 579402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 580402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Print title line 581402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<h3>Performance of "); 582402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (!isGlobal) { 583402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(component); 584402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(": "); 585402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 586402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(currentName); 587402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(" relative to "); 588402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int index = baselineName.indexOf('_'); 589402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (index > 0) { 590402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(baselineName.substring(0, index)); 591402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(" ("); 592402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll index = baselineName.lastIndexOf('_'); 593402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(baselineName.substring(index+1, baselineName.length())); 594402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(')'); 595402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 596402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(baselineName); 597402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 598402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("</h3>\n"); 599402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 600402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Print reference to global results 601402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (!isGlobal) { 602402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<?php\n"); 603402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(" $type=$_SERVER['QUERY_STRING'];\n"); 604402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(" if ($type==\"\") {\n"); 605402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(" $type=\"fp_type=0\";\n"); 606402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(" }\n"); 607402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(" $href=\"<a href=\\\"performance.php?\";\n"); 608402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(" $href=$href . $type . \"\\\">Back to global results</a><br><br>\";\n"); 609402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(" echo $href;\n"); 610402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("?>\n"); 611402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 612402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 613402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 614402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* 615402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Print summary of coefficient of variation for each scenario of the given pattern 616402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * both for baseline and current builds. 617402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 618402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void printSummary(/*PerformanceResults performanceResults*/) { 619402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll long start = System.currentTimeMillis(); 620402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.printStream != null) this.printStream.print("Print scenarios variations summary..."); 621402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll File outputFile = new File(this.outputDir, "cvsummary.html"); 622402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll PrintStream stream = null; 623402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 624402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream = new PrintStream(new BufferedOutputStream(new FileOutputStream(outputFile))); 625402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printSummaryPresentation(stream); 626402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll// List scenarioNames = DB_Results.getScenarios(); 627402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll// int size = scenarioNames.size(); 628402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] components = this.performanceResults.getComponents(); 629402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int componentsLength = components.length; 630402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printSummaryColumnsTitle(stream/*, performanceResults*/); 631402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] configs = this.performanceResults.getConfigNames(true/*sorted*/); 632402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int configsLength = configs.length; 633402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int i=0; i<componentsLength; i++) { 634402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String componentName = components[i]; 635402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll List scenarioNames = this.performanceResults.getComponentScenarios(componentName); 636402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int size = scenarioNames.size(); 637402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int s=0; s<size; s++) { 638402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String scenarioName = ((ScenarioResults) scenarioNames.get(s)).getName(); 639402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (scenarioName == null) continue; 640402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ScenarioResults scenarioResults = this.performanceResults.getScenarioResults(scenarioName); 641402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (scenarioResults != null) { 642402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<tr>\n"); 643402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int j=0; j<2; j++) { 644402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int c=0; c<configsLength; c++) { 645402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printSummaryScenarioLine(j, configs[c], scenarioResults, stream); 646402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 647402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 648402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<td>"); 649402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(scenarioName); 650402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("</td></tr>\n"); 651402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 652402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 653402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 654402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (Exception e) { 655402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll e.printStackTrace(); 656402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } finally { 657402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("</table></body></html>\n"); 658402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.flush(); 659402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.close(); 660402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 661402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.printStream != null) this.printStream.println("done in "+(System.currentTimeMillis()-start)+"ms"); 662402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 663402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 664402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* 665402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Print summary presentation (eg. file start and text presenting the purpose of this file contents).. 666402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 667402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void printSummaryPresentation(PrintStream stream) { 668402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(Utils.HTML_OPEN); 669402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(Utils.HTML_DEFAULT_CSS); 670402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<title>Summary of Elapsed Process Variation Coefficients</title></head>\n"); 671402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<body><h3>Summary of Elapsed Process Variation Coefficients</h3>\n"); 672402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<p> This table provides a bird's eye view of variability in elapsed process times\n"); 673402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("for baseline and current build stream performance scenarios."); 674402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(" This summary is provided to facilitate the identification of scenarios that should be examined due to high variability."); 675402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("The variability for each scenario is expressed as a <a href=\"http://en.wikipedia.org/wiki/Coefficient_of_variation\">coefficient\n"); 676402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("of variation</a> (CV). The CV is calculated by dividing the <b>standard deviation\n"); 677402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("of the elapse process time over builds</b> by the <b>average elapsed process\n"); 678402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("time over builds</b> and multiplying by 100.\n"); 679402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("</p><p>High CV values may be indicative of any of the following:<br></p>\n"); 680402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<ol><li> an unstable performance test. </li>\n"); 681402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<ul><li>may be evidenced by an erratic elapsed process line graph.<br><br></li></ul>\n"); 682402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<li>performance regressions or improvements at some time in the course of builds.</li>\n"); 683402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<ul><li>may be evidenced by plateaus in elapsed process line graphs.<br><br></li></ul>\n"); 684402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<li>unstable testing hardware.\n"); 685402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<ul><li>consistent higher CV values for one test configuration as compared to others across"); 686402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(" scenarios may be related to hardward problems.</li></ul></li></ol>\n"); 687402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<p> Scenarios are listed in alphabetical order in the far right column. A scenario's\n"); 688402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("variation coefficients (CVs) are in columns to the left for baseline and current\n"); 689402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("build streams for each test configuration. Scenarios with CVs > 10% are highlighted\n"); 690402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("in yellow (10%<CV><CV<20%) and orange(CV>20%). </p>\n"); 691402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<p> Each CV value links to the scenario's detailed results to allow viewers to\n"); 692402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("investigate the variability.</p>\n"); 693402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 694402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 695402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* 696402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Print columns titles of the summary table. 697402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 698402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void printSummaryColumnsTitle(PrintStream stream/*, PerformanceResults performanceResults*/) { 699402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] configBoxes = this.performanceResults.getConfigBoxes(true/*sorted*/); 700402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = configBoxes.length; 701402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<table border=\"1\"><tr><td colspan=\""); 702402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(length); 703402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("\"><b>Baseline CVs</b></td><td colspan=\""); 704402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(length); 705402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("\"><b>Current Build Stream CVs</b></td><td rowspan=\"2\"><b>Scenario Name</b></td></tr>\n"); 706402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<tr>"); 707402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int n=0; n<2; n++) { 708402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int c=0; c<length; c++) { 709402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<td>"); 710402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(configBoxes[c]); 711402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("</td>"); 712402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 713402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 714402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("</tr>\n"); 715402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 716402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 717402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* 718402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Print a scenario line in the summary table. 719402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 720402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void printSummaryScenarioLine(int i, String config, ScenarioResults scenarioResults, PrintStream stream) { 721402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ConfigResults configResults = scenarioResults.getConfigResults(config); 722402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (configResults == null || !configResults.isValid()) { 723402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<td>n/a</td>"); 724402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return; 725402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 726402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String url = config + "/" + scenarioResults.getFileName()+".html"; 727402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll double[] stats = null; 728402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (i==0) { // baseline results 729402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll List baselinePrefixes; 730402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.baselinePrefix == null) { 731402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll baselinePrefixes = Util.BASELINE_BUILD_PREFIXES; 732402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 733402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll baselinePrefixes = new ArrayList(); 734402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll baselinePrefixes.add(this.baselinePrefix); 735402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 736402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stats = configResults.getStatistics(baselinePrefixes); 737402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 738402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stats = configResults.getStatistics(this.currentBuildPrefixes); 739402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 740402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll double variation = stats[3]; 741402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (variation > 0.1 && variation < 0.2) { 742402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<td bgcolor=\"yellow\">"); 743402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else if (variation >= 0.2) { 744402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<td bgcolor=\"FF9900\">"); 745402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 746402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<td>"); 747402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 748402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("<a href=\""); 749402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(url); 750402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("\"/>"); 751402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print(Util.PERCENTAGE_FORMAT.format(variation)); 752402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll stream.print("</a></td>"); 753402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 754402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 755402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* 756402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Print usage in case one of the argument of the line was incorrect. 757402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Note that calling this method ends the program run due to final System.exit() 758402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 759402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void printUsage() { 760402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println( 761402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "Usage:\n\n" + 762402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "-baseline\n" + 763402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Build id against which to compare results.\n" + 764402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Same as value specified for the \"build\" key in the eclipse.perf.config system property.\n\n" + 765402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 766402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "[-baseline.prefix]\n" + 767402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Optional. Build id prefix used in baseline test builds and reruns. Used to plot baseline historical data.\n" + 768402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " A common prefix used for the value of the \"build\" key in the eclipse.perf.config system property when rerunning baseline tests.\n\n" + 769402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 770402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "-current\n" + 771402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " build id for which to generate results. Compared to build id specified in -baseline parameter above.\n" + 772402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Same as value specified for the \"build\" key in the eclipse.perf.config system property. \n\n" + 773402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 774402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "[-current.prefix]\n" + 775402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Optional. Comma separated list of build id prefixes used in current build stream.\n" + 776402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Used to plot current build stream historical data. Defaults to \"N,I\".\n" + 777402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Prefixes for values specified for the \"build\" key in the eclipse.perf.config system property. \n\n" + 778402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 779402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "-jvm\n" + 780402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Value specified in \"jvm\" key in eclipse.perf.config system property for current build.\n\n" + 781402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 782402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "-config\n" + 783402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Comma separated list of config names for which to generate results.\n" + 784402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Same as values specified in \"config\" key in eclipse.perf.config system property.\n\n" + 785402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 786402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "-output\n" + 787402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Path to default output directory.\n\n" + 788402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 789402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "[-config.properties]\n" + 790402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Optional. Used by scenario status table to provide the following:\n" + 791402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " alternate descriptions of config values to use in columns.\n" + 792402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " The value should be specified in the following format:\n" + 793402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " name1,description1;name2,description2;etc..\n\n" + 794402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 795402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "[-highlight]\n" + 796402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Optional. Comma-separated list of build Id prefixes used to find most recent matching for each entry.\n" + 797402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Result used to highlight points in line graphs.\n\n" + 798402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 799402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "[-scenario.pattern]\n" + 800402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Optional. Scenario prefix pattern to query database. If not specified,\n" + 801402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " default of % used in query.\n\n" + 802402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 803402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "[-fingerprints]\n" + 804402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Optional. Use to generate fingerprints only.\n\n" + 805402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 806402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "[-data]\n" + 807402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Optional. Generates table of scenario reference and current data with line graphs.\n\n" + 808402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 809402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "[-print]\n" + 810402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Optional. Display output in the console while generating.\n" + 811402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 812402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "[-nophp]\n" + 813402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Optional. Generate files for non-php server.\n" + 814402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 815402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "[-failure.threshold]\n" + 816402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll " Optional. Set the failure percentage threshold (default is 10%).\n" 817402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ); 818402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 819402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.exit(1); 820402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 821402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 822402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 823402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Run the generation from a list of arguments. 824402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Typically used to generate results from an application. 825402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 826402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic IStatus run(String[] args) { 827402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll parse(args); 828402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return run((IProgressMonitor) null); 829402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 830402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 831402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 832402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Run the generation using a progress monitor. 833402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Note that all necessary information to generate properly must be set before 834402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * calling this method 835402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 836402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @see #run(String[]) 837402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 838402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic IStatus run(final IProgressMonitor monitor) { 839402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll long begin = System.currentTimeMillis(); 840402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int work = 1100; 841402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int dataWork = 1000 * this.performanceResults.getConfigBoxes(false).length; 842402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.genAll || this.genData) { 843402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll work += dataWork; 844402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 845402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll SubMonitor subMonitor = SubMonitor.convert(monitor, work); 846402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 847402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 848402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Print whole scenarios summary 849402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.printStream != null) this.printStream.println(); 850402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printSummary(/*performanceResults*/); 851402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 852402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Copy images and scripts to output dir 853402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Bundle bundle = UiPlugin.getDefault().getBundle(); 854402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll// URL images = bundle.getEntry("images"); 855402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll// if (images != null) { 856402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll// images = FileLocator.resolve(images); 857402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll// Utils.copyImages(new File(images.getPath()), this.outputDir); 858402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll// } 859402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /* New way to get images 860402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll File content = FileLocator.getBundleFile(bundle); 861402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll BundleFile bundleFile; 862402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (content.isDirectory()) { 863402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll bundleFile = new DirBundleFile(content); 864402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Utils.copyImages(bundleFile.getFile("images", true), this.outputDir); 865402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 866402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll bundleFile = new ZipBundleFile(content, null); 867402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Enumeration imageFiles = bundle.findEntries("images", "*.gif", false); 868402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll while (imageFiles.hasMoreElements()) { 869402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll URL url = (URL) imageFiles.nextElement(); 870402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Utils.copyFile(bundleFile.getFile("images"+File.separator+, true), this.outputDir); 871402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 872402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 873402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 874402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Copy bundle files 875402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Utils.copyBundleFiles(bundle, "images", "*.gif", this.outputDir); // images 876402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Utils.copyBundleFiles(bundle, "scripts", "*.js", this.outputDir); // java scripts 877402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Utils.copyBundleFiles(bundle, "scripts", "*.css", this.outputDir); // styles 878402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Utils.copyBundleFiles(bundle, "doc", "*.html", this.outputDir); // doc 879402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Utils.copyBundleFiles(bundle, "doc/images", "*.png", this.outputDir); // images for doc 880402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /* 881402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll URL doc = bundle.getEntry("doc"); 882402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (doc != null) { 883402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll doc = FileLocator.resolve(doc); 884402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll File docDir = new File(doc.getPath()); 885402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll FileFilter filter = new FileFilter() { 886402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public boolean accept(File pathname) { 887402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return !pathname.getName().equals("CVS"); 888402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 889402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll }; 890402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll File[] docFiles = docDir.listFiles(filter); 891402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int i=0; i<docFiles.length; i++) { 892402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll File file = docFiles[i]; 893402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (file.isDirectory()) { 894402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll File subdir = new File(this.outputDir, file.getName()); 895402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll subdir.mkdir(); 896402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll File[] subdirFiles = file.listFiles(filter); 897402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int j=0; j<subdirFiles.length; j++) { 898402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (subdirFiles[i].isDirectory()) { 899402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // expect only one sub-directory 900402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 901402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Util.copyFile(subdirFiles[j], new File(subdir, subdirFiles[j].getName())); 902402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 903402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 904402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 905402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Util.copyFile(file, new File(this.outputDir, file.getName())); 906402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 907402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 908402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 909402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 910402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 911402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Print HTML pages and all linked files 912402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.printStream != null) { 913402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.printStream.println("Print performance results HTML pages:"); 914402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.printStream.print(" - components main page"); 915402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 916402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll long start = System.currentTimeMillis(); 917402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll subMonitor.setTaskName("Write fingerprints: 0%"); 918402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll subMonitor.subTask("Global..."); 919402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printComponent(/*performanceResults, */"global_fp"); 920402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll subMonitor.worked(100); 921402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (subMonitor.isCanceled()) throw new OperationCanceledException(); 922402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] components = this.performanceResults.getComponents(); 923402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = components.length; 924402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int step = 1000 / length; 925402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int progress = 0; 926402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int i=0; i<length; i++) { 927402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int percentage = (int) ((progress / ((double) length)) * 100); 928402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll subMonitor.setTaskName("Write fingerprints: "+percentage+"%"); 929402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll subMonitor.subTask(components[i]+"..."); 930402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll printComponent(/*performanceResults, */components[i]); 931402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll subMonitor.worked(step); 932402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (subMonitor.isCanceled()) throw new OperationCanceledException(); 933402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll progress++; 934402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 935402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.printStream != null) { 936402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String duration = Util.timeString(System.currentTimeMillis()-start); 937402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.printStream.println(" done in "+duration); 938402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 939402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 940402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Print the scenarios data 941402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.genData || this.genAll) { 942402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll start = System.currentTimeMillis(); 943402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.printStream != null) this.printStream.println(" - all scenarios data:"); 944402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ScenarioData data = new ScenarioData(this.baselinePrefix, this.pointsOfInterest, this.currentBuildPrefixes, this.outputDir); 945402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 946402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll data.print(this.performanceResults, this.printStream, subMonitor.newChild(dataWork)); 947402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (Exception ex) { 948402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ex.printStackTrace(); 949402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 950402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.printStream != null) { 951402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String duration = Util.timeString(System.currentTimeMillis()-start); 952402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.printStream.println(" => done in "+duration); 953402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 954402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 955402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.printStream != null) { 956402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll long time = System.currentTimeMillis(); 957402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.printStream.println("End of generation: "+new SimpleDateFormat("H:mm:ss").format(new Date(time))); 958402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String duration = Util.timeString(System.currentTimeMillis()-begin); 959402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.printStream.println("=> done in "+duration); 960402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 961402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return new Status(IStatus.OK, UiPlugin.getDefault().toString(), "Everything is OK"); 962402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 963402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll catch (OperationCanceledException oce) { 964402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return new Status(IStatus.OK, UiPlugin.getDefault().toString(), "Generation was cancelled!"); 965402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 966402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll catch (Exception ex) { 967402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return new Status(IStatus.ERROR, UiPlugin.getDefault().toString(), "An unexpected exception occurred!", ex); 968402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 969402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll finally { 970402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.printStream != null) { 971402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.printStream.flush(); 972402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.printStream != System.out) { 973402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.printStream.close(); 974402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 975402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 976402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 977402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 978402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 979402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void setDefaults(String buildName, String baseline) { 980402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (buildName == null) { 981402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buildName = this.performanceResults.getName(); 982402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 983402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 984402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Set default output dir if not set 985402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.outputDir.getPath().indexOf(buildName) == -1) { 986402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll File dir = new File(this.outputDir, buildName); 987402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (dir.exists() || dir.mkdir()) { 988402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.outputDir = dir; 989402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.printStream != null) { 990402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.printStream.println(" + changed output dir to: "+dir.getPath()); 991402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 992402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 993402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 994402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 995402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Verify that build is known 996402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] builds = this.performanceResults.getAllBuildNames(); 997402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (builds == null || builds.length == 0) { 998402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.err.println("Cannot connect to database to generate results build '"+buildName+"'"); 999402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.exit(1); 1000402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1001402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (Arrays.binarySearch(builds, buildName, Util.BUILD_DATE_COMPARATOR) < 0) { 1002402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll throw new RuntimeException("No results in database for build '"+buildName+"'"); 1003402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1004402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.printStream != null) { 1005402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.printStream.println(); 1006402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.printStream.flush(); 1007402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1008402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1009402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Init baseline prefix if not set 1010402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.baselinePrefix == null) { 1011402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int index = baseline.lastIndexOf('_'); 1012402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (index > 0) { 1013402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.baselinePrefix = baseline.substring(0, index); 1014402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 1015402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.baselinePrefix = DB_Results.getDbBaselinePrefix(); 1016402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1017402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1018402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1019402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Init current build prefixes if not set 1020402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.currentBuildPrefixes == null) { 1021402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.currentBuildPrefixes = new ArrayList(); 1022402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (buildName.charAt(0) == 'M') { 1023402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.currentBuildPrefixes.add("M"); 1024402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 1025402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.currentBuildPrefixes.add("N"); 1026402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1027402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.currentBuildPrefixes.add("I"); 1028402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1029402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 1030402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1031402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void setPerformanceResults(String buildName, String baselineName) { 1032402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1033402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Set performance results 1034402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.performanceResults = new PerformanceResults(buildName, baselineName, this.baselinePrefix, this.printStream); 1035402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1036402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Set defaults 1037402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll setDefaults(buildName, this.performanceResults.getBaselineName()); 1038402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1039402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Read performance results data 1040402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.performanceResults.readAll(buildName, this.configDescriptors, this.scenarioPattern, this.dataDir, this.failure_threshold, null); 1041402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 1042402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1043402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* (non-Javadoc) 1044402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @see org.eclipse.equinox.app.IApplication#stop() 1045402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 1046402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic void stop() { 1047402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Do nothing 1048402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 1049402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1050402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}