Mercurial > hg > orthanc
comparison OrthancFramework/Sources/Toolbox.cpp @ 5390:1c3b0cf341f0
Toolbox: added ElapsedTimeLogger debug tool
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 26 Sep 2023 12:28:13 +0200 |
parents | be0b9c407985 |
children | b83192e7ad10 |
comparison
equal
deleted
inserted
replaced
5389:0e5e675b9750 | 5390:1c3b0cf341f0 |
---|---|
2511 value[value.size() - 1] == '\"') | 2511 value[value.size() - 1] == '\"') |
2512 { | 2512 { |
2513 value = value.substr(1, value.size() - 2); | 2513 value = value.substr(1, value.size() - 2); |
2514 } | 2514 } |
2515 } | 2515 } |
2516 | |
2517 Toolbox::ElapsedTimeLogger::ElapsedTimeLogger(const std::string& message) | |
2518 : message_(message), | |
2519 logged_(false) | |
2520 { | |
2521 Restart(); | |
2522 } | |
2523 | |
2524 Toolbox::ElapsedTimeLogger::~ElapsedTimeLogger() | |
2525 { | |
2526 if (!logged_) | |
2527 { | |
2528 StopAndLog(); | |
2529 } | |
2530 } | |
2531 | |
2532 void Toolbox::ElapsedTimeLogger::Restart() | |
2533 { | |
2534 start_ = boost::posix_time::microsec_clock::universal_time(); | |
2535 } | |
2536 | |
2537 void Toolbox::ElapsedTimeLogger::StopAndLog() | |
2538 { | |
2539 boost::posix_time::ptime now = boost::posix_time::microsec_clock::universal_time(); | |
2540 boost::posix_time::time_duration diff = now - start_; | |
2541 LOG(WARNING) << "ELAPSED TIMER: " << message_ << " (" << diff.total_microseconds() << " us)"; | |
2542 logged_ = true; | |
2543 } | |
2544 | |
2545 | |
2516 } | 2546 } |
2517 | 2547 |
2518 | 2548 |
2519 | 2549 |
2520 OrthancLinesIterator* OrthancLinesIterator_Create(const std::string& content) | 2550 OrthancLinesIterator* OrthancLinesIterator_Create(const std::string& content) |