# HG changeset patch # User Benjamin Golinvaux # Date 1614002221 -3600 # Node ID 946eb7200b824e4fe1ef955699cfff2019ee1b31 # Parent 5f74ebe2516b24250081ee44d8d6daa58dac5466 FastParseVector usage + timing instrumentation guarded by STONE_TIME_BLOCKING_OPS diff -r 5f74ebe2516b -r 946eb7200b82 OrthancStone/Sources/Loaders/DicomStructureSetLoader.cpp --- a/OrthancStone/Sources/Loaders/DicomStructureSetLoader.cpp Mon Feb 22 14:56:06 2021 +0100 +++ b/OrthancStone/Sources/Loaders/DicomStructureSetLoader.cpp Mon Feb 22 14:57:01 2021 +0100 @@ -28,6 +28,10 @@ #include +#if STONE_TIME_BLOCKING_OPS +# include +#endif + #include namespace OrthancStone @@ -187,6 +191,10 @@ virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message) ORTHANC_OVERRIDE { +#if STONE_TIME_BLOCKING_OPS + boost::posix_time::ptime timerStart = boost::posix_time::microsec_clock::universal_time(); +#endif + DicomStructureSetLoader& loader = GetLoader(); // Set the actual structure set content @@ -219,6 +227,13 @@ } loader.RetrieveReferencedSlices(nonEmptyInstances); +#if STONE_TIME_BLOCKING_OPS + boost::posix_time::ptime timerEnd = boost::posix_time::microsec_clock::universal_time(); + boost::posix_time::time_duration duration = timerEnd - timerStart; + int64_t durationMs = duration.total_milliseconds(); + LOG(WARNING) << "DicomStructureSetLoader::LoadStructure::Handle took " << durationMs << " ms"; +#endif + } void SetDefaultStructureVisibility() diff -r 5f74ebe2516b -r 946eb7200b82 OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.cpp --- a/OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.cpp Mon Feb 22 14:56:06 2021 +0100 +++ b/OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.cpp Mon Feb 22 14:57:01 2021 +0100 @@ -25,6 +25,10 @@ #include #include +#if STONE_TIME_BLOCKING_OPS +# include +#endif + namespace OrthancStone { class OrthancMultiframeVolumeLoader::LoadRTDoseGeometry : public LoaderStateMachine::State @@ -267,6 +271,10 @@ void OrthancMultiframeVolumeLoader::CopyPixelDataAndComputeDistribution( const std::string& pixelData, std::map& distribution) { +#if STONE_TIME_BLOCKING_OPS + boost::posix_time::ptime timerStart = boost::posix_time::microsec_clock::universal_time(); +#endif + ImageBuffer3D& target = volume_->GetPixelData(); const unsigned int bpp = target.GetBytesPerPixel(); @@ -354,6 +362,12 @@ #endif } } +#if STONE_TIME_BLOCKING_OPS + boost::posix_time::ptime timerEnd = boost::posix_time::microsec_clock::universal_time(); + boost::posix_time::time_duration duration = timerEnd - timerStart; + int64_t durationMs = duration.total_milliseconds(); + LOG(WARNING) << "OrthancMultiframeVolumeLoader::CopyPixelDataAndComputeDistribution took " << durationMs << " ms"; +#endif } template diff -r 5f74ebe2516b -r 946eb7200b82 OrthancStone/Sources/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp --- a/OrthancStone/Sources/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp Mon Feb 22 14:56:06 2021 +0100 +++ b/OrthancStone/Sources/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp Mon Feb 22 14:57:01 2021 +0100 @@ -33,6 +33,9 @@ #include #include +#if STONE_TIME_BLOCKING_OPS +# include +#endif namespace OrthancStone { @@ -338,6 +341,10 @@ */ void OrthancSeriesVolumeProgressiveLoader::LoadGeometry(const OrthancRestApiCommand::SuccessMessage& message) { +#if STONE_TIME_BLOCKING_OPS + boost::posix_time::ptime timerStart = boost::posix_time::microsec_clock::universal_time(); +#endif + Json::Value body; message.ParseJsonBody(body); @@ -404,6 +411,14 @@ slicesQuality_.resize(slicesCount, 0); BroadcastMessage(DicomVolumeImage::GeometryReadyMessage(*volume_)); + +#if STONE_TIME_BLOCKING_OPS + boost::posix_time::ptime timerEnd = boost::posix_time::microsec_clock::universal_time(); + boost::posix_time::time_duration duration = timerEnd - timerStart; + int64_t durationMs = duration.total_milliseconds(); + LOG(WARNING) << "OrthancSeriesVolumeProgressiveLoader::LoadGeometry took " << durationMs << " ms"; +#endif + } diff -r 5f74ebe2516b -r 946eb7200b82 OrthancStone/Sources/Toolbox/DicomStructureSet.cpp --- a/OrthancStone/Sources/Toolbox/DicomStructureSet.cpp Mon Feb 22 14:56:06 2021 +0100 +++ b/OrthancStone/Sources/Toolbox/DicomStructureSet.cpp Mon Feb 22 14:57:01 2021 +0100 @@ -23,7 +23,9 @@ #include "DicomStructureSet.h" #include "DicomStructureSetUtils.h" -#include "../Toolbox/GeometryToolbox.h" +#include "GeometryToolbox.h" +#include "GenericToolbox.h" + #include "OrthancDatasets/DicomDatasetReader.h" #include @@ -35,6 +37,10 @@ # pragma warning(disable:4244) #endif +#if STONE_TIME_BLOCKING_OPS +# include +#endif + #include #include #include @@ -163,13 +169,13 @@ } - static bool ParseVector(Vector& target, + static bool FastParseVector(Vector& target, const IDicomDataset& dataset, const DicomPath& tag) { std::string value; return (dataset.GetStringValue(value, tag) && - LinearAlgebra::ParseVector(target, value)); + GenericToolbox::FastParseVector(target, value)); } void DicomStructureSet::Polygon::CheckPointIsOnSlice(const Vector& v) const @@ -468,6 +474,10 @@ void DicomStructureSet::Setup(const IDicomDataset& tags) { +#if STONE_TIME_BLOCKING_OPS + boost::posix_time::ptime timerStart = boost::posix_time::microsec_clock::universal_time(); +#endif + DicomDatasetReader reader(tags); size_t count, tmp; @@ -481,6 +491,9 @@ } structures_.resize(count); +#if STONE_TIME_BLOCKING_OPS + LOG(WARNING) << "DicomStructureSet::Setup(...) structures_.size() = " << structures_.size(); +#endif for (size_t i = 0; i < count; i++) { structures_[i].interpretation_ = reader.GetStringValue @@ -494,7 +507,7 @@ "No name"); Vector color; - if (ParseVector(color, tags, DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, + if (FastParseVector(color, tags, DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, DICOM_TAG_ROI_DISPLAY_COLOR)) && color.size() == 3) { @@ -516,6 +529,10 @@ countSlices = 0; } +#if STONE_TIME_BLOCKING_OPS + LOG(WARNING) << "DicomStructureSet::Setup(...) structure # " << i << " : countSlices = " << countSlices; +#endif + LOG(INFO) << "New RT structure: \"" << structures_[i].name_ << "\" with interpretation \"" << structures_[i].interpretation_ << "\" containing " << countSlices << " slices (color: " @@ -582,7 +599,8 @@ std::string slicesData = reader.GetMandatoryStringValue(contourDataPath); Vector points; - if (!LinearAlgebra::ParseVector(points, slicesData) || + + if (!GenericToolbox::FastParseVector(points, slicesData) || points.size() != 3 * countPoints) { throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); @@ -609,6 +627,12 @@ structures_[i].polygons_.push_back(polygon); } } +#if STONE_TIME_BLOCKING_OPS + boost::posix_time::ptime timerEnd = boost::posix_time::microsec_clock::universal_time(); + boost::posix_time::time_duration duration = timerEnd - timerStart; + int64_t durationMs = duration.total_milliseconds(); + LOG(WARNING) << "DicomStructureSet::Setup took " << durationMs << " ms"; +#endif } diff -r 5f74ebe2516b -r 946eb7200b82 OrthancStone/Sources/Toolbox/DicomStructureSet2.cpp --- a/OrthancStone/Sources/Toolbox/DicomStructureSet2.cpp Mon Feb 22 14:56:06 2021 +0100 +++ b/OrthancStone/Sources/Toolbox/DicomStructureSet2.cpp Mon Feb 22 14:57:01 2021 +0100 @@ -71,7 +71,7 @@ { std::string value; return (dataset.GetStringValue(value, tag) && - LinearAlgebra::ParseVector(target, value)); + GenericToolbox::FastParseVector(target, value)); } @@ -271,7 +271,7 @@ std::string slicesData = reader.GetMandatoryStringValue(contourDataPath); Vector points; - if (!LinearAlgebra::ParseVector(points, slicesData) || + if (!GenericToolbox::FastParseVector(points, slicesData) || points.size() != 3 * countPoints) { throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);