public interface DerivedComputation
The metric is reported when Timing.dumpTimings()
is called.
The metric can be registered with Timing.registerDerivedComputation()
.
Below is an example in which the effective CPU throughput for computing an FFT
is calculated based on the size of the FFT and the amount of time it took on average to
compute it.
import static java.lang.Math.log;
final public class LoopTimes {
public static StopWatch internalLoopTiming =
Timing
.createAndRegisterStatistic("internal loop time")
.suppressIfValueIsZero();
public static int iter;
public static int nFFT;
public static DerivedComputation internalGflops;
public static final Double ZERO = new Double(0.0);
static {
Timing.stripBaseName("org.mitre");
Timing.registerDerivedComputation("gflops (internal)",
internalGflops=new DerivedComputation(){
@Override
public String getComputedString() {
Number val = getComputedNumber();
if (val == ZERO) return null;
return val.toString() + " Gflops";
}
@Override
public Number getComputedNumber() {
if (internalLoopTiming.getCount() == 0){
return ZERO;
}
else {
double mx = (int)(log(nFFT)/log(2)+0.001);
double time = internalLoopTiming.getCumulative();
double gflops = (5.0 * mx * nFFT * iter)/(time);
return new Double(gflops);
}
}
});
}
}
Modifier and Type | Method and Description |
---|---|
java.lang.Number |
getComputedNumber()
This is NOT called when timings are dumped.
|
java.lang.String |
getComputedString()
This is called when timings are dumped.
|
java.lang.String getComputedString()
java.lang.Number getComputedNumber()