Scopes that are not under TDZ should still push their variables onto the TDZ stack...
[WebKit-https.git] / Source / WTF / benchmarks / LockFairnessTest.cpp
index e808908..59cf858 100644 (file)
@@ -48,12 +48,13 @@ namespace {
 
 NO_RETURN void usage()
 {
-    printf("Usage: LockFairnessTest yieldspinlock|pausespinlock|wordlock|lock|barginglock|bargingwordlock|thunderlock|thunderwordlock|cascadelock|cascadewordlockhandofflock|mutex|all <num threads> <seconds per test>\n");
+    printf("Usage: LockFairnessTest yieldspinlock|pausespinlock|wordlock|lock|barginglock|bargingwordlock|thunderlock|thunderwordlock|cascadelock|cascadewordlockhandofflock|mutex|all <num threads> <seconds per test> <microseconds in critical section>\n");
     exit(1);
 }
 
 unsigned numThreads;
 double secondsPerTest;
+unsigned microsecondsInCriticalSection;
 
 struct Benchmark {
     template<typename LockType>
@@ -72,9 +73,19 @@ struct Benchmark {
             threads[threadIndex] = createThread(
                 "Benchmark Thread",
                 [&, threadIndex] () {
+                    if (!microsecondsInCriticalSection) {
+                        while (keepGoing) {
+                            lock.lock();
+                            counts[threadIndex]++;
+                            lock.unlock();
+                        }
+                        return;
+                    }
+                    
                     while (keepGoing) {
                         lock.lock();
                         counts[threadIndex]++;
+                        usleep(microsecondsInCriticalSection);
                         lock.unlock();
                     }
                 });
@@ -106,9 +117,10 @@ int main(int argc, char** argv)
 {
     WTF::initializeThreading();
     
-    if (argc != 4
+    if (argc != 5
         || sscanf(argv[2], "%u", &numThreads) != 1
-        || sscanf(argv[3], "%lf", &secondsPerTest) != 1)
+        || sscanf(argv[3], "%lf", &secondsPerTest) != 1
+        || sscanf(argv[4], "%u", &microsecondsInCriticalSection) != 1)
         usage();
     
     runEverything<Benchmark>(argv[1]);