/*******************************************************************************
* Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.test.performance.ui;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.test.internal.performance.data.Dim;
import org.eclipse.test.internal.performance.results.db.BuildResults;
import org.eclipse.test.internal.performance.results.db.ConfigResults;
import org.eclipse.test.internal.performance.results.db.DB_Results;
import org.eclipse.test.internal.performance.results.utils.Util;
/**
* Class used to fill details file of scenario builds data.
* @see ScenarioData
*/
public class RawDataTable {
private ConfigResults configResults;
private List buildPrefixes;
private PrintStream stream;
private Dim[] dimensions = DB_Results.getResultsDimensions();
private boolean debug = false;
private RawDataTable(ConfigResults results, PrintStream ps) {
this.configResults = results;
this.stream = ps;
}
public RawDataTable(ConfigResults results, List prefixes, PrintStream ps) {
this(results, ps);
this.buildPrefixes = prefixes;
}
public RawDataTable(ConfigResults results, String baselinePrefix, PrintStream ps) {
this(results, ps);
this.buildPrefixes = new ArrayList();
this.buildPrefixes.add(baselinePrefix);
}
/**
* Print all build data to the current stream.
*/
public void print(){
this.stream.print("
");
printSummary();
printDetails();
this.stream.print("
\n");
}
/*
* Print table columns headers.
*/
private void printColumnHeaders() {
StringBuffer buffer = new StringBuffer();
int length = this.dimensions.length;
for (int i=0; i");
buffer.append(this.dimensions[i].getName());
buffer.append("");
}
this.stream.print(buffer.toString());
}
/*
* Print all build results in the table.
*/
private void printDetails() {
this.stream.print("Build ID | ");
printColumnHeaders();
this.stream.print("
\n");
List builds = this.configResults.getBuildsMatchingPrefixes(this.buildPrefixes);
Collections.reverse(builds);
int size = builds.size();
for (int i=0; i");
this.stream.print(buildResults.getName());
this.stream.print(" | ");
int dimLength = this.dimensions.length;
for (int d=0; d");
}
if (this.debug) System.out.println();
this.stream.print("\n");
}
if (this.debug) System.out.println("\n");
}
/*
* Print summary on top of the table.
*/
private void printSummary() {
this.stream.print("Stats | ");
printColumnHeaders();
this.stream.print("
\n");
int length = this.dimensions.length;
double[][] dimStats = new double[length][];
for (int i=0; i#BUILDS SAMPLED | ");
for (int i=0; i");
}
this.stream.print("\n");
this.stream.print("MEAN | ");
printRowDoubles(dimStats, 1);
this.stream.print("
\n");
this.stream.print("STD DEV | ");
printRowDoubles(dimStats, 2);
this.stream.print("
\n");
this.stream.print("COEF. VAR | ");
printRowDoubles(dimStats, 3);
this.stream.print("
\n");
// Blank line
this.stream.print("");
for (int i=0; i ");
}
this.stream.print("
\n");
}
/*
* Print values in table row.
*/
private void printRowDoubles(double[][] stats, int idx) {
int length = this.dimensions.length;
for (int i=0; i 0.1 && value < 0.2) {
this.stream.print("= 0.2) {
this.stream.print(" | ");
this.stream.print(Util.PERCENTAGE_FORMAT.format(value));
this.stream.print(" | ");
} else {
printDimTitle(dimName);
this.stream.print(this.dimensions[i].getDisplayValue(value));
this.stream.print("");
}
}
}
/*
* Print dim title inside value reference.
* TODO (frederic) See if this title is really necessary
*/
private void printDimTitle(String dimName) {
this.stream.print("");
}
}
|