Search in sources :

Example 1 with Assumption

use of nl.javadude.assumeng.Assumption in project bioformats by openmicroscopy.

the class OpenBytesPerformanceTest method testOpenBytesAllTilesPreAllocatedBuffer.

@Test(dependsOnMethods = { "setId" })
@Assumption(methods = "isNotBigImage")
public void testOpenBytesAllTilesPreAllocatedBuffer() throws Exception {
    for (int series = 0; series < seriesCount; series++) {
        assertSeries(series);
        for (int image = 0; image < imageCount; image++) {
            LOGGER.info("Reading from series {} image {}", series, image);
            optimalTileWidth = reader.getOptimalTileWidth();
            optimalTileHeight = reader.getOptimalTileHeight();
            LOGGER.info("Optimal tile {}x{}", optimalTileWidth, optimalTileHeight);
            int tilesWide = (int) Math.ceil((double) sizeX / optimalTileWidth);
            int tilesHigh = (int) Math.ceil((double) sizeY / optimalTileHeight);
            LOGGER.info("Tile counts {}x{}", tilesWide, tilesHigh);
            int x, y = 0;
            StopWatch stopWatch;
            byte[] buf = new byte[optimalTileWidth * optimalTileHeight * FormatTools.getBytesPerPixel(reader.getPixelType())];
            LOGGER.info("Allocated buffer size: {}", buf.length);
            for (int tileX = 0; tileX < tilesWide; tileX++) {
                for (int tileY = 0; tileY < tilesHigh; tileY++) {
                    x = tileX * optimalTileWidth;
                    y = tileY * optimalTileHeight;
                    int actualTileWidth = (int) Math.min(optimalTileWidth, reader.getSizeX() - x);
                    int actualTileHeight = (int) Math.min(optimalTileHeight, reader.getSizeY() - y);
                    LOGGER.info("Reading tile at {}x{}", x, y);
                    stopWatch = new Slf4JStopWatch(String.format("%s.prealloc_tile.%s.[%d:%d]", ((ReaderWrapper) reader).unwrap().getClass().getName(), filename, series, image));
                    reader.openBytes(image, buf, x, y, actualTileWidth, actualTileHeight);
                    stopWatch.stop();
                }
            }
        }
    }
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch) Test(org.testng.annotations.Test) Assumption(nl.javadude.assumeng.Assumption)

Aggregations

Assumption (nl.javadude.assumeng.Assumption)1 StopWatch (org.perf4j.StopWatch)1 Slf4JStopWatch (org.perf4j.slf4j.Slf4JStopWatch)1 Test (org.testng.annotations.Test)1