diff Plugins/Samples/Common/OrthancPluginCppWrapper.cpp @ 3179:fca730c267d7

New primitives to set and refresh metrics
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 30 Jan 2019 17:12:15 +0100
parents 4e43e67f8ecf
children 872efde28e58
line wrap: on
line diff
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Wed Jan 30 12:41:20 2019 +0100
+++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Wed Jan 30 17:12:15 2019 +0100
@@ -2033,4 +2033,21 @@
     }
   }
 #endif
+
+
+#if HAS_ORTHANC_PLUGIN_METRICS == 1
+  MetricsTimer::MetricsTimer(const char* name) :
+    name_(name)
+  {
+    start_ = boost::posix_time::microsec_clock::universal_time();
+  }
+  
+  MetricsTimer::~MetricsTimer()
+  {
+    const boost::posix_time::ptime stop = boost::posix_time::microsec_clock::universal_time();
+    const boost::posix_time::time_duration diff = stop - start_;
+    OrthancPluginSetMetricsValue(GetGlobalContext(), name_.c_str(), diff.total_milliseconds(),
+                                 OrthancPluginMetricsType_Timer);
+  }
+#endif
 }