[3/4] BENCHMARK: add a benchmark for testing new type of mutex
Commit Message
Add the benchmark for testing the mutex with type
PTHREAD_MUTEX_QUEUESPINNER_NP.
Signed-off-by: Kemi Wang <kemi.wang@intel.com>
---
benchtests/Makefile | 4 ++--
benchtests/bench-mutex-adaptive-thread.c | 8 ++++++--
benchtests/bench-mutex-queuespinner-thread.c | 21 +++++++++++++++++++++
3 files changed, 29 insertions(+), 4 deletions(-)
create mode 100644 benchtests/bench-mutex-queuespinner-thread.c
@@ -96,7 +96,7 @@ bench-malloc := $(filter malloc-%,${BENCHSET})
endif
ifeq (${BENCHSET},)
-bench-mutex := mutex-adaptive-thread
+bench-mutex := mutex-adaptive-thread mutex-queuespinner-thread
else
bench-mutex := $(filter mutex-%,${BENCHSET})
endif
@@ -174,7 +174,7 @@ bench-clean:
ifneq ($(strip ${BENCHSET}),)
VALIDBENCHSETNAMES := bench-pthread bench-math bench-string string-benchset \
wcsmbs-benchset stdlib-benchset stdio-common-benchset math-benchset \
- malloc-thread mutex-adaptive-thread
+ malloc-thread mutex-adaptive-thread mutex-queuespinner-thread
INVALIDBENCHSETNAMES := $(filter-out ${VALIDBENCHSETNAMES},${BENCHSET})
ifneq (${INVALIDBENCHSETNAMES},)
$(info The following values in BENCHSET are invalid: ${INVALIDBENCHSETNAMES})
@@ -30,8 +30,12 @@
#include "json-lib.h"
/* Benchmark duration in seconds. */
-#define BENCHMARK_DURATION 15
-#define TYPE PTHREAD_MUTEX_ADAPTIVE_NP
+#define BENCHMARK_DURATION 5
+
+#ifndef TYPE
+# define TYPE PTHREAD_MUTEX_ADAPTIVE_NP
+#endif
+
#define mb() asm ("" ::: "memory")
#define UNLOCK_DELAY 10
new file mode 100644
@@ -0,0 +1,21 @@
+/* Benchmark pthread adaptive spin mutex lock and unlock functions.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TYPE PTHREAD_MUTEX_QUEUESPINNER_NP
+
+#include "bench-mutex-adaptive-thread.c"