]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
add udiffNoReset for running time measurements
authorBert Hubert <bert.hubert@netherlabs.nl>
Thu, 3 Feb 2011 14:54:06 +0000 (14:54 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Thu, 3 Feb 2011 14:54:06 +0000 (14:54 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1968 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/misc.hh

index b39c59d0e45a3613b48ea1e88e08ff9c4dab1f24..4c6169ca2cc8418be764f3f0546d4e6f06f81879 100644 (file)
@@ -203,6 +203,7 @@ public:
   time_t time();
   inline void set();  //!< Reset the timer
   inline int udiff(); //!< Return the number of microseconds since the timer was last set.
+  inline int udiffNoReset(); //!< Return the number of microseconds since the timer was last set.
   void setTimeval(const struct timeval& tv)
   {
     d_set=tv;
@@ -223,15 +224,22 @@ inline void DTime::set()
 }
 
 inline int DTime::udiff()
+{
+  int res=udiffNoReset();
+  Utility::gettimeofday(&d_set,0);
+  return res;
+}
+
+inline int DTime::udiffNoReset()
 {
   struct timeval now;
 
   Utility::gettimeofday(&now,0);
   int ret=1000000*(now.tv_sec-d_set.tv_sec)+(now.tv_usec-d_set.tv_usec);
-  d_set=now;
   return ret;
 }
 
+
 inline bool dns_isspace(char c)
 {
   return c==' ' || c=='\t' || c=='\r' || c=='\n';