@@ -85,7 +85,7 @@ std::unique_ptr<uchar[]> ImagePyramidAccess::getPatchDataChar(int level, int x,
8585 (y - (y/tileHeight)*tileHeight) + height <= tileHeight
8686 ) {
8787 // We only need to read 1 tile
88- mRuntimeManager ->startRegularTimer (" simple " );
88+ mRuntimeManager ->startRegularTimer (" simple_crop " );
8989 auto tileData = std::make_unique<uchar[]>(tileWidth*tileHeight*bytesPerPixel);
9090 {
9191 // From TIFFReadTile documentation: Return the data for the tile containing the specified coordinates.
@@ -124,7 +124,7 @@ std::unique_ptr<uchar[]> ImagePyramidAccess::getPatchDataChar(int level, int x,
124124 }
125125 }
126126 mRuntimeManager ->stopRegularTimer (" Crop tile" );
127- mRuntimeManager ->stopRegularTimer (" simple " );
127+ mRuntimeManager ->stopRegularTimer (" simple_crop " );
128128 } else {
129129 mRuntimeManager ->startRegularTimer (" full" );
130130 // Create buffer to contain all tiles
@@ -220,7 +220,9 @@ std::unique_ptr<uchar[]> ImagePyramidAccess::getPatchDataChar(int level, int x,
220220 }
221221 } else if (m_fileHandle != nullptr ) {
222222 int scale = (float )m_image->getFullWidth ()/levelWidth;
223+ mRuntimeManager ->startRegularTimer (" openslide_read_region" );
223224 openslide_read_region (m_fileHandle, (uint32_t *)data.get (), x * scale, y * scale, level, width, height);
225+ mRuntimeManager ->stopRegularTimer (" openslide_read_region" );
224226 }
225227
226228 return data;
@@ -253,7 +255,9 @@ std::shared_ptr<Image> ImagePyramidAccess::getPatchAsImage(int level, int offset
253255 case TYPE_UINT8:
254256 {
255257 auto data = getPatchData<uchar>(level, offsetX, offsetY, width, height);
258+ mRuntimeManager ->startRegularTimer (" create_image_object" );
256259 image = Image::create (width, height, m_image->getDataType (), m_image->getNrOfChannels (), std::move (data));
260+ mRuntimeManager ->stopRegularTimer (" create_image_object" );
257261 }
258262 break ;
259263 case TYPE_UINT16:
@@ -294,12 +298,14 @@ std::shared_ptr<Image> ImagePyramidAccess::getPatchAsImage(int level, int offset
294298 SceneGraph::setParentNode (image, std::dynamic_pointer_cast<SpatialDataObject>(m_image));
295299
296300 if (m_fileHandle != nullptr && convertToRGB) {
301+ mRuntimeManager ->startRegularTimer (" convert_to_rgb" );
297302 // Data is stored as BGRA, need to delete alpha channel and reverse it
298303 auto channelConverter = ImageChannelConverter::New ();
299304 channelConverter->setChannelsToRemove (false , false , false , true );
300305 channelConverter->setReverseChannels (true );
301306 channelConverter->setInputData (image);
302307 image = channelConverter->updateAndGetOutputData <Image>();
308+ mRuntimeManager ->stopRegularTimer (" convert_to_rgb" );
303309 }
304310 return image;
305311}
@@ -368,10 +374,14 @@ uint32_t ImagePyramidAccess::writeTileToTIFF(int level, int x, int y, Image::poi
368374 if (m_image->getCompression () == ImageCompression::NEURAL_NETWORK) {
369375 return writeTileToTIFFNeuralNetwork (level, x, y, image);
370376 } else if (m_image->getCompression () == ImageCompression::JPEGXL) {
377+ mRuntimeManager ->startRegularTimer (" get_image_access_for_writing" );
371378 auto access = image->getImageAccess (ACCESS_READ);
379+ mRuntimeManager ->stopRegularTimer (" get_image_access_for_writing" );
372380 return writeTileToTIFFJPEGXL (level, x, y, (uchar*)access->get ());
373381 } else if (m_image->getCompression () == ImageCompression::JPEG) {
382+ mRuntimeManager ->startRegularTimer (" get_image_access_for_writing" );
374383 auto access = image->getImageAccess (ACCESS_READ);
384+ mRuntimeManager ->stopRegularTimer (" get_image_access_for_writing" );
375385 return writeTileToTIFFJPEG (level, x, y, (uchar*)access->get ());
376386 } else {
377387 auto access = image->getImageAccess (ACCESS_READ);
@@ -390,28 +400,36 @@ uint32_t ImagePyramidAccess::writeTileToTIFF(int level, int x, int y, uchar *dat
390400
391401uint32_t ImagePyramidAccess::writeTileToTIFFJPEGXL (int level, int x, int y, uchar *data) {
392402 std::lock_guard<std::mutex> lock (m_readMutex);
393- TIFFSetDirectory (m_tiffHandle, level);
394- uint32_t tile_id = TIFFComputeTile (m_tiffHandle, x, y, 0 , 0 );
403+ mRuntimeManager ->startRegularTimer (" jpegxl_compression" );
395404 JPEGXLCompression jxl;
396405 std::vector<uchar> compressed;
397406 jxl.compress (data, m_image->getLevelTileWidth (level), m_image->getLevelTileHeight (level), &compressed, m_image->getCompressionQuality ());
407+ mRuntimeManager ->stopRegularTimer (" jpegxl_compression" );
408+ mRuntimeManager ->startRegularTimer (" tiff_write_tile" );
409+ TIFFSetDirectory (m_tiffHandle, level);
410+ uint32_t tile_id = TIFFComputeTile (m_tiffHandle, x, y, 0 , 0 );
398411 TIFFSetWriteOffset (m_tiffHandle, 0 ); // Set write offset to 0, so that we dont appen data
399412 TIFFWriteRawTile (m_tiffHandle, tile_id, (void *) compressed.data (), compressed.size ()); // This appends data..
400413 TIFFCheckpointDirectory (m_tiffHandle);
414+ mRuntimeManager ->stopRegularTimer (" tiff_write_tile" );
401415 return tile_id;
402416}
403417
404418
405419uint32_t ImagePyramidAccess::writeTileToTIFFJPEG (int level, int x, int y, uchar *data) {
406420 std::lock_guard<std::mutex> lock (m_readMutex);
407- TIFFSetDirectory (m_tiffHandle, level);
408- uint32_t tile_id = TIFFComputeTile (m_tiffHandle, x, y, 0 , 0 );
421+ mRuntimeManager ->startRegularTimer (" jpeg_compression" );
409422 JPEGCompression jpeg;
410423 std::vector<uchar> compressed;
411424 jpeg.compress (data, m_image->getLevelTileWidth (level), m_image->getLevelTileHeight (level), &compressed, m_image->getCompressionQuality ());
425+ mRuntimeManager ->stopRegularTimer (" jpeg_compression" );
426+ mRuntimeManager ->startRegularTimer (" tiff_write_tile" );
427+ TIFFSetDirectory (m_tiffHandle, level);
428+ uint32_t tile_id = TIFFComputeTile (m_tiffHandle, x, y, 0 , 0 );
412429 TIFFSetWriteOffset (m_tiffHandle, 0 ); // Set write offset to 0, so that we dont appen data
413430 TIFFWriteRawTile (m_tiffHandle, tile_id, (void *) compressed.data (), compressed.size ()); // This appends data..
414431 TIFFCheckpointDirectory (m_tiffHandle);
432+ mRuntimeManager ->stopRegularTimer (" tiff_write_tile" );
415433 return tile_id;
416434}
417435
@@ -441,6 +459,7 @@ void ImagePyramidAccess::setPatch(int level, int x, int y, Image::pointer patch,
441459 throw Exception (" setPatch only available for TIFF backend ImagePyramids" );
442460
443461 if (m_image->getLevelTileWidth (level) > patch->getWidth () || m_image->getLevelTileHeight (level) > patch->getHeight ()) {
462+ mRuntimeManager ->startRegularTimer (" padding" );
444463 // Padding needed
445464 auto paddedImage = Image::create (m_image->getLevelTileWidth (level), m_image->getLevelTileHeight (level), patch->getDataType (), m_image->getNrOfChannels ());
446465 if (m_image->getNrOfChannels () >= 3 ) {
@@ -458,6 +477,7 @@ void ImagePyramidAccess::setPatch(int level, int x, int y, Image::pointer patch,
458477 device->getCommandQueue ().finish ();
459478 }
460479 patch = paddedImage;
480+ mRuntimeManager ->stopRegularTimer (" padding" );
461481 }
462482
463483 // Write tile to this level
@@ -675,13 +695,15 @@ void ImagePyramidAccess::setBlankPatch(int level, int x, int y) {
675695 throw Exception (" setBlankPatch only available for TIFF backend ImagePyramids" );
676696
677697 std::lock_guard<std::mutex> lock (m_readMutex);
698+ mRuntimeManager ->startRegularTimer (" write_blank_patch" );
678699 TIFFSetDirectory (m_tiffHandle, level);
679700 uint32_t tile_id = TIFFComputeTile (m_tiffHandle, x, y, 0 , 0 );
680701 TIFFSetWriteOffset (m_tiffHandle, 0 ); // Set write offset to 0, so that we dont appen data
681702 // Writing zero bytes, will produce a warning, thus we write 1 byte
682703 char data = 0 ;
683704 TIFFWriteRawTile (m_tiffHandle, tile_id, &data, 0 );
684705 TIFFCheckpointDirectory (m_tiffHandle);
706+ mRuntimeManager ->stopRegularTimer (" write_blank_patch" );
685707 m_initializedPatchList.insert (std::to_string (level) + " -" + std::to_string (tile_id));
686708
687709 // TODO Propagate or not?
0 commit comments