Java Code Profiling
Here is a very small Java class to help time function calls or sections of code. Of course, it won’t be exactly right on (due to scheduling issues, etc), but it’s pretty good at helping with initial profiling and performance measurements.
public class Stopwatch
{
private long start;
private long stop;
public void start()
{
// start timing
start = System.currentTimeMillis();
}
public void stop()
{
// stop timing
stop = System.currentTimeMillis();
}
public long elapsedTimeMillis()
{
return stop - start;
}
public String toString()
{
// print execution time
return "elapsedTimeMillis: " + Long.toString(elapsedTimeMillis());
}
}
Sorry, I don’t have any code for this algorithm, just thought it was interesting. A quick search might reveal some useful code.
can I have the java code on leaky bucket algorithim?