grep
?
/** Definition and preconditions as before. */ public static long presentValue(long investment, int rate, int years) { int modified_rate = 100 + rate; // For computation // Each year, update the investment by the interest for(int i = 0; i < years; ++i) { investment = investment * modified_rate / 100; // Note that "investment *= modified-rate / 100" won't work. } // for return investment; } // presentValue
/bin/time
or /time
.
System.currentTimeMillis()
is a relatively
efficient way of getting "the number of milliseconds since (some
standard date, probably January 1, 1970 G.S.T.).
before = System.currentTimeMillis(); System.out.println("The result of our complicated function is " + complicateFunction(alpha,beta,gamma)); after = System.currentTimeMillis(); System.out.println("That computation took " + (after-before) + " milliseconds.");
% java_g -prof Class
java.prof
.
% java_g -prof:prof-file Class
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
Source text last modified Wed Nov 12 10:09:12 1997.
This page generated on Wed Nov 12 10:42:23 1997 by SiteWeaver.
Contact our webmaster at rebelsky@math.grin.edu