]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
speedtest: Move the increment inside the loop for lock tests 10216/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 30 Mar 2021 08:23:08 +0000 (10:23 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 30 Mar 2021 08:23:08 +0000 (10:23 +0200)
pdns/speedtest.cc

index 078acd058c75c4d179f9b63b26189914b986fc95..80702f2800d7e5c1ac4cc4b6508be62e6e7f1c9e 100644 (file)
@@ -872,9 +872,8 @@ struct ReadWriteLockSharedTest
   string getName() const { return "RW lock shared"; }
 
   void operator()() const {
-    for (size_t idx = 0; idx < 1000; ) {
+    for (size_t idx = 0; idx < 1000; idx++) {
       ReadLock wl(d_lock);
-      ++idx;
     }
   }
 
@@ -891,9 +890,8 @@ struct ReadWriteLockExclusiveTest
   string getName() const { return "RW lock exclusive"; }
 
   void operator()() const {
-    for (size_t idx = 0; idx < 1000; ) {
+    for (size_t idx = 0; idx < 1000; idx++) {
       WriteLock wl(d_lock);
-      ++idx;
     }
   }
 
@@ -910,7 +908,7 @@ struct ReadWriteLockExclusiveTryTest
   string getName() const { return "RW lock try exclusive - " + std::string(d_contended ? "contended" : "non-contended"); }
 
   void operator()() const {
-    for (size_t idx = 0; idx < 1000; ) {
+    for (size_t idx = 0; idx < 1000; idx++) {
       TryWriteLock wl(d_lock);
       if (!wl.gotIt() && !d_contended) {
         cerr<<"Error getting the lock"<<endl;
@@ -920,7 +918,6 @@ struct ReadWriteLockExclusiveTryTest
         cerr<<"Got a contended lock"<<endl;
         _exit(0);
       }
-      ++idx;
     }
   }
 
@@ -938,7 +935,7 @@ struct ReadWriteLockSharedTryTest
   string getName() const { return "RW lock try shared - " + std::string(d_contended ? "contended" : "non-contended"); }
 
   void operator()() const {
-    for (size_t idx = 0; idx < 1000; ) {
+    for (size_t idx = 0; idx < 1000; idx++) {
       TryReadLock wl(d_lock);
       if (!wl.gotIt() && !d_contended) {
         cerr<<"Error getting the lock"<<endl;
@@ -948,7 +945,6 @@ struct ReadWriteLockSharedTryTest
         cerr<<"Got a contended lock"<<endl;
         _exit(0);
       }
-      ++idx;
     }
   }