Search in sources :

Example 36 with Slf4JStopWatch

use of org.perf4j.slf4j.Slf4JStopWatch 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)

Example 37 with Slf4JStopWatch

use of org.perf4j.slf4j.Slf4JStopWatch in project bioformats by openmicroscopy.

the class OpenBytesPerformanceTest method testOpenBytesAllTilesNewBuffer.

@Test(dependsOnMethods = { "setId" })
public void testOpenBytesAllTilesNewBuffer() 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;
            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.alloc_tile.%s.[%d:%d]", ((ReaderWrapper) reader).unwrap().getClass().getName(), filename, series, image));
                    reader.openBytes(0, 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)

Aggregations

StopWatch (org.perf4j.StopWatch)37 Slf4JStopWatch (org.perf4j.slf4j.Slf4JStopWatch)37 UIPerformanceLogger (com.haulmont.cuba.gui.logging.UIPerformanceLogger)17 Element (org.dom4j.Element)4 Transaction (com.haulmont.cuba.core.Transaction)3 Test (org.testng.annotations.Test)3 Node (com.haulmont.bali.datastruct.Node)2 MetaClass (com.haulmont.chile.core.model.MetaClass)2 AppFolder (com.haulmont.cuba.core.entity.AppFolder)2 ComponentLoader (com.haulmont.cuba.gui.xml.layout.ComponentLoader)2 ComponentLoaderContext (com.haulmont.cuba.gui.xml.layout.loaders.ComponentLoaderContext)2 SearchFolder (com.haulmont.cuba.security.entity.SearchFolder)2 Binding (groovy.lang.Binding)2 IOException (java.io.IOException)2 Pair (com.haulmont.bali.datastruct.Pair)1 Tree (com.haulmont.bali.datastruct.Tree)1 MetaModel (com.haulmont.chile.core.model.MetaModel)1 MetaProperty (com.haulmont.chile.core.model.MetaProperty)1 EntityManager (com.haulmont.cuba.core.EntityManager)1 Entity (com.haulmont.cuba.core.entity.Entity)1