Mercurial > hg > orthanc
comparison OrthancFramework/Sources/Toolbox.h @ 5390:1c3b0cf341f0
Toolbox: added ElapsedTimeLogger debug tool
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 26 Sep 2023 12:28:13 +0200 |
parents | b31c73bc7cb6 |
children | b83192e7ad10 |
comparison
equal
deleted
inserted
replaced
5389:0e5e675b9750 | 5390:1c3b0cf341f0 |
---|---|
65 | 65 |
66 #if ORTHANC_ENABLE_PUGIXML == 1 | 66 #if ORTHANC_ENABLE_PUGIXML == 1 |
67 # include <pugixml.hpp> | 67 # include <pugixml.hpp> |
68 #endif | 68 #endif |
69 | 69 |
70 #include <boost/date_time/posix_time/posix_time.hpp> | |
71 | |
70 | 72 |
71 namespace Orthanc | 73 namespace Orthanc |
72 { | 74 { |
73 typedef std::vector<std::string> UriComponents; | 75 typedef std::vector<std::string> UriComponents; |
74 | 76 |
371 | 373 |
372 static void WriteStyledJson(std::string& target, | 374 static void WriteStyledJson(std::string& target, |
373 const Json::Value& source); | 375 const Json::Value& source); |
374 | 376 |
375 static void RemoveSurroundingQuotes(std::string& value); | 377 static void RemoveSurroundingQuotes(std::string& value); |
378 | |
379 // This is a helper class to measure and log time spend e.g in a method. | |
380 // This should be used only during debugging and should likely not ever used in a release. | |
381 // By default, you should use it as a RAII but you may force Restart/StopAndLog manually if needed. | |
382 class ORTHANC_PUBLIC ElapsedTimeLogger | |
383 { | |
384 private: | |
385 const std::string message_; | |
386 boost::posix_time::ptime start_; | |
387 bool logged_; | |
388 | |
389 public: | |
390 explicit ElapsedTimeLogger(const std::string& message); | |
391 ~ElapsedTimeLogger(); | |
392 | |
393 void Restart(); | |
394 void StopAndLog(); | |
395 }; | |
396 | |
376 }; | 397 }; |
377 } | 398 } |
378 | 399 |
379 | 400 |
380 | 401 |