FileDocCategorySizeDatePackage
ScaleChart.javaAPI DocExample3342Thu Feb 04 16:10:44 GMT 1999None

ScaleChart

public class ScaleChart extends Object

Fields Summary
private int
nIter
private int
nRows
private int
nCols
private int
nThreads
Class
target
Constructors Summary
ScaleChart(int nIter, int nRows, int nCols, int nThreads, String className)


	          
		this.nIter = nIter;
		this.nRows = nRows;
		this.nCols = nCols;
		this.nThreads = nThreads;
		try {
			target = Class.forName(className);
		} catch (ClassNotFoundException cnfe) {
			System.out.println(cnfe);
			System.exit(-1);
		}
	
Methods Summary
voidchart()

		long sumTime = 0;
		long startLoop = System.currentTimeMillis();
		try {
			ScaleTester st = (ScaleTester) target.newInstance();
			for (int i = 0; i < nIter; i++) {
				st.init(nRows, nCols, nThreads);
				long then = System.currentTimeMillis();
				float ans[][] = st.doCalc();
				long now = System.currentTimeMillis();
				sumTime += (now - then);
				if (nIter == 1)
					dump(ans, System.out);
			}
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(-1);
		}
		long endLoop = System.currentTimeMillis();
		long calcTime = endLoop - startLoop;
		System.err.println("Loop time " + sumTime +
				 " (" + ((sumTime * 100) / calcTime) + "%)");
		System.err.println("Calculation time  " + calcTime);
	
private voiddump(float[][] ans, java.io.PrintStream ps)

		NumberFormat nf = NumberFormat.getInstance();
		nf.setMaximumFractionDigits(4);
		for (int i = 0; i < ans.length; i++) {
			for (int j = 0; j < ans[i].length; j++)
				ps.print(nf.format(ans[i][j]) + " ");
			ps.println("");
		}
	
public static voidmain(java.lang.String[] args)

		if (args.length != 5) {
			System.out.println("Usage: java ScaleTester nIter nRows nCols nThreads className");
			System.exit(-1);
		}
		ScaleChart sc = new ScaleChart(Integer.parseInt(args[0]),
										Integer.parseInt(args[1]),
										Integer.parseInt(args[2]),
										Integer.parseInt(args[3]),
										args[4]);
		CPUSupport.setConcurrency(Integer.parseInt(args[3]) + 5);
		sc.chart();