changeset 1751:946eb7200b82

FastParseVector usage + timing instrumentation guarded by STONE_TIME_BLOCKING_OPS
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 22 Feb 2021 14:57:01 +0100
parents 5f74ebe2516b
children 63e893267c98
files OrthancStone/Sources/Loaders/DicomStructureSetLoader.cpp OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.cpp OrthancStone/Sources/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp OrthancStone/Sources/Toolbox/DicomStructureSet.cpp OrthancStone/Sources/Toolbox/DicomStructureSet2.cpp
diffstat 5 files changed, 75 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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 <Toolbox.h>
 
+#if STONE_TIME_BLOCKING_OPS
+# include <boost/date_time/posix_time/posix_time.hpp>
+#endif
+
 #include <algorithm>
 
 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<DicomStructureSetLoader>();
 
       // 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()
--- 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 <Endianness.h>
 #include <Toolbox.h>
 
+#if STONE_TIME_BLOCKING_OPS
+# include <boost/date_time/posix_time/posix_time.hpp>
+#endif
+
 namespace OrthancStone
 {
   class OrthancMultiframeVolumeLoader::LoadRTDoseGeometry : public LoaderStateMachine::State
@@ -267,6 +271,10 @@
   void OrthancMultiframeVolumeLoader::CopyPixelDataAndComputeDistribution(
     const std::string& pixelData, std::map<T,uint64_t>& 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 <typename T>
--- 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 <Images/ImageProcessing.h>
 #include <OrthancException.h>
 
+#if STONE_TIME_BLOCKING_OPS
+# include <boost/date_time/posix_time/posix_time.hpp>
+#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
+
   }
 
 
--- 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 <Logging.h>
@@ -35,6 +37,10 @@
 #  pragma warning(disable:4244)
 #endif
 
+#if STONE_TIME_BLOCKING_OPS
+# include <boost/date_time/posix_time/posix_time.hpp>
+#endif
+
 #include <limits>
 #include <stdio.h>
 #include <boost/geometry.hpp>
@@ -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
   }
 
 
--- 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);