Именно то, что я делаю,
FileOutputStream out;
PrintStream outputfile;
try{
out = new FileOutputStream("Project1.txt");
outputfile = new PrintStream(out);
int a[ ] = { 4, -3, 5, -2, -1, 2, 6, -2 };
int maxSum;
Formatter fmt = new Formatter();
//Setup table column titles
outputfile.println(fmt.format("%12s %12s %12s %12s %12s %12s%n", "Algorithm", "n", "time", "time/n^3", "time/n^2", "time/(n*log(n))"));
outputfile.println(fmt.format("%12s %12s %12s %12s %12s %12s%n%n", "_________", "_", "(ms)", "x100,000", "x10,000", "x10,000"));
// Algorithm 1
for( int n = 256; n <= 2049; n *= 2 ){
int alg = 1;
long timing;
maxSum = maxSubSum1( a );
timing = getTimingInfo( n, alg );
double time = (((double)timing)/1000000.0);
outputfile.println(fmt.format("%12s %12d %12f %12f %12f %12f%n", "Alg. 1", n, time, (time/(((long)n)*n*n))*100000.0, (time/(n*n))*10000, (time/((double)n*Math.log((double)n)))*10000));
}
}
catch(Exception e)
{
System.err.println("Error in writing to file");
}
Получен некоторый вывод, на который я ссылаюсь,
Algorithm n time time/n^3 time/n^2 time/(n*log(n))
Algorithm n time time/n^3 time/n^2 time/(n*log(n))
_________ _ (ms) x100,000 x10,000 x10,000
Algorithm n time time/n^3 time/n^2 time/(n*log(n))
_________ _ (ms) x100,000 x10,000 x10,000
Alg. 1 256 4.335838 0.025844 0.661596 30.543418