import java.util.*; import java.util.Scanner; import java.io.*; public class TestingShell { // Results will be appended to file each time program is run. static String RESULTS_FILE_NAME = "ExperimentResults.txt"; public static void main(String[] args) throws Exception { experiment01(); } public static void experiment01() { // Loop - probably have a loop here long bTime = System.nanoTime(); // algorithm long eTime = System.nanoTime(); displayRunTime( "informative message?", bTime, eTime ); // End Loop } //----------------------------------------------------------------------- // Helper Methods //----------------------------------------------------------------------- private static double randDouble(double a, double b) { return a + (b*Math.random()); } private static void displayRunTime( String msg, long bTime, long eTime ) { long tTime = eTime-bTime; double runTimeSeconds = tTime/1000000000.0; String output = String.format( "%s %d %f", msg, tTime, runTimeSeconds ); // Write output string to console. System.out.println( output ); // Write output string to text file. File outFile = new File( RESULTS_FILE_NAME ); try { FileWriter fw = new FileWriter( outFile, true ); PrintWriter writer = new PrintWriter( fw ); writer.println( output ); writer.close(); } catch(IOException e ) { } } }