keeps track of wall-clock time inside a program.

Overview

Surround parts of your code that you want to time with "start" and "stop" commands. At the end, create a report. This is a very simple-minded approach for summarizing how fast a program runs. It only keeps track of wall clock time, so the results will vary with machine load.

Example

Put some static calls around what interests you:
StopwatchCollection.start("realize");
NounList sourceData = (NounList)etc.calculateRealization(itsObs[j]);
StopwatchCollection.stop("realize");
To make a report, create a PrintStream and send the report to it:
FileOutputStream fout = new FileOutputStream("stopwatch.txt");
PrintStream ps = new PrintStream(fout);
ps.println("stopwatch output for TimingTestWithDatabase");
ps.println("nFilters="+nFilters);
ps.println("targetListOriginal.size()="+targetListOriginal.size());
ps.println("sequenceListOriginal.size()="+sequenceListOriginal.size());
StopwatchCollection.report(ps);
fout.close();
If you "forgot" to stop a stopwatch, an informative warning will go to the PrintStream.

You can also make a plot of the number of seconds since a stopwatch was reset (or created) vs. the count of the number of times it was stopped.

StopwatchCollection.plot("Save Supernovae","TimingTestWithDatabaseSupernova");

Warning

Putting in too many of these calls will slow down your program.

You have to keep track of the stopwatch names yourself. If you start a name that does not exist, a new stopwatch will be created. If you try to do anything else to a stopwatch name that does not exist, you will be ignored silently.