ywkaras commented on code in PR #9394:
URL: https://github.com/apache/trafficserver/pull/9394#discussion_r1111110852


##########
src/tscpp/util/unit_tests/benchmark_shared_mutex.cc:
##########
@@ -0,0 +1,130 @@
+/** @file
+
+  Micro Benchmark tool for shared_mutex - requires Catch2 v2.9.0+
+
+  - e.g. example of running 64 threads with read/write rate is 100:1
+  ```
+  $ taskset -c 0-63 ./benchmark_shared_mutex --ts-nthreads 64 --ts-nloop 1000 
--ts-nread 100 --ts-nwrite 1
+  ```
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+      http://www.apache.org/licenses/LICENSE-2.0
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+#define CATCH_CONFIG_ENABLE_BENCHMARKING
+#define CATCH_CONFIG_RUNNER
+
+#include "catch.hpp"
+
+#include "tscpp/util/Bravo.h"
+
+#include <mutex>
+#include <shared_mutex>
+#include <thread>
+
+namespace
+{
+// Args
+struct Conf {
+  int nloop    = 1;
+  int nthreads = 1;
+  int nread    = 1;
+  int nwrite   = 1;
+};
+
+Conf conf;
+thread_local int counter = 0;
+
+template <typename T, typename S>
+void
+run(T &mutex)
+{
+  std::thread list[conf.nthreads];
+
+  for (int i = 0; i < conf.nthreads; i++) {
+    new (&list[i]) std::thread{[](T &mutex) {

Review Comment:
   It seems like the only advantage of using a lambda here is that you avoid 
having to pick a name for the thread function.  I think it would be more 
readable just using a conventional, named function for the thread function.
   
   On the other hand, @SolidWallOfCode smiles and sighs with contentment 
whenever anyone uses a lambda, so there is that.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to