use of uk.ac.sussex.gdsc.test.utils.TimingService in project GDSC-SMLM by aherbert.
the class GaussianFilterTest method floatFilterIsFasterThanDoubleFilter.
@SpeedTag
@SeededTest
void floatFilterIsFasterThanDoubleFilter(RandomSeed seed) {
Assumptions.assumeTrue(TestSettings.allow(TestComplexity.MEDIUM));
final UniformRandomProvider rg = RngUtils.create(seed.getSeed());
final float[][] data = new float[10][];
for (int i = 0; i < data.length; i++) {
data[i] = createData(rg, size, size);
}
final TimingService ts = new TimingService();
for (final double sigma : sigmas) {
ts.execute(new MyTimingTask(new FloatFilter(false), data, sigma));
ts.execute(new MyTimingTask(new DpFilter(false), data, sigma));
ts.execute(new MyTimingTask(new DoubleFilter(false), data, sigma));
}
final int size = ts.getSize();
ts.repeat();
if (logger.isLoggable(Level.INFO)) {
logger.info(ts.getReport(size));
}
final int n = size / sigmas.length;
for (int i = 0, j = size; i < sigmas.length; i++, j += n) {
for (int k = 1; k < n; k++) {
final TimingResult slow = ts.get(j + k);
final TimingResult fast = ts.get(j);
logger.log(TestLogUtils.getTimingRecord(slow, fast));
}
}
}
use of uk.ac.sussex.gdsc.test.utils.TimingService in project GDSC-SMLM by aherbert.
the class KernelFilterTest method floatFilterIsFasterThanImageJFilter.
private void floatFilterIsFasterThanImageJFilter(RandomSeed seed, int kw) {
Assumptions.assumeTrue(TestSettings.allow(TestComplexity.MEDIUM));
final UniformRandomProvider rg = RngUtils.create(seed.getSeed());
final float[][] data = new float[10][];
for (int i = 0; i < data.length; i++) {
data[i] = createData(rg, size, size);
}
final float[] kernel = createKernel(kw, kw);
for (final int border : borders) {
final TimingService ts = new TimingService();
ts.execute(new MyTimingTask(new ConvolverWrapper(kernel, kw, kw), data, border));
ts.execute(new MyTimingTask(new KernelFilterWrapper(kernel, kw, kw), data, border));
ts.execute(new MyTimingTask(new ZeroKernelFilterWrapper(kernel, kw, kw), data, border));
final int size = ts.getSize();
ts.repeat();
if (logger.isLoggable(Level.INFO)) {
logger.info(ts.getReport(size));
}
logger.log(TestLogUtils.getTimingRecord(ts.get(-3), ts.get(-1)));
}
}
use of uk.ac.sussex.gdsc.test.utils.TimingService in project GDSC-SMLM by aherbert.
the class FilterTest method directCompareMultiFilterIsFaster.
@SeededTest
void directCompareMultiFilterIsFaster(RandomSeed seed) {
Assumptions.assumeTrue(TestSettings.allow(TestComplexity.MEDIUM));
final UniformRandomProvider UniformRandomProvider = RngUtils.create(seed.getSeed());
final MultiFilter f1 = new MultiFilter(0, 0, 0, 0, 0, 0, 0, 0, 0);
final MultiFilter2 f2 = new MultiFilter2(0, 0, 0, 0, 0, 0, 0, 0, 0);
final double[][][] data = new double[1000][][];
for (int i = data.length; i-- > 0; ) {
data[i] = new double[][] { random(f1.getNumberOfParameters(), UniformRandomProvider), random(f1.getNumberOfParameters(), UniformRandomProvider) };
}
final TimingService ts = new TimingService();
ts.execute(new BaseTimingTask("MultiFilter") {
@Override
public Object getData(int index) {
return new MultiFilter[] { (MultiFilter) f1.create(data[index][0]), (MultiFilter) f1.create(data[index][1]) };
}
@Override
public Object run(Object data) {
final MultiFilter f1 = ((MultiFilter[]) data)[0];
final MultiFilter f2 = ((MultiFilter[]) data)[1];
f1.weakest((Filter) f2);
return null;
}
@Override
public int getSize() {
return data.length;
}
});
ts.execute(new BaseTimingTask("MultiFilter direct") {
@Override
public Object getData(int index) {
return new MultiFilter[] { (MultiFilter) f1.create(data[index][0]), (MultiFilter) f1.create(data[index][1]) };
}
@Override
public Object run(Object data) {
final MultiFilter f1 = ((MultiFilter[]) data)[0];
final MultiFilter f2 = ((MultiFilter[]) data)[1];
f1.weakest(f2);
return null;
}
@Override
public int getSize() {
return data.length;
}
});
ts.execute(new BaseTimingTask("MultiFilter2") {
@Override
public Object getData(int index) {
return new MultiFilter2[] { (MultiFilter2) f2.create(data[index][0]), (MultiFilter2) f2.create(data[index][1]) };
}
@Override
public Object run(Object data) {
final MultiFilter2 f1 = ((MultiFilter2[]) data)[0];
final MultiFilter2 f2 = ((MultiFilter2[]) data)[1];
f1.weakest((Filter) f2);
return null;
}
@Override
public int getSize() {
return data.length;
}
});
ts.execute(new BaseTimingTask("MultiFilter2 direct") {
@Override
public Object getData(int index) {
return new MultiFilter2[] { (MultiFilter2) f2.create(data[index][0]), (MultiFilter2) f2.create(data[index][1]) };
}
@Override
public Object run(Object data) {
final MultiFilter2 f1 = ((MultiFilter2[]) data)[0];
final MultiFilter2 f2 = ((MultiFilter2[]) data)[1];
f1.weakest(f2);
return null;
}
@Override
public int getSize() {
return data.length;
}
});
ts.check();
final int size = ts.repeat();
ts.repeat(size);
if (logger.isLoggable(Level.INFO)) {
logger.info(ts.getReport(size));
}
for (int i = 0; i < size; i += 2) {
final TimingResult slow = ts.get(-(i + 2));
final TimingResult fast = ts.get(-(i + 1));
Assertions.assertTrue(slow.getMin() > fast.getMin());
}
}
Aggregations