From 50214916ced979018625164b1bd311c4a890f695 Mon Sep 17 00:00:00 2001 From: Shane Snyder Date: Mon, 18 Mar 2024 15:23:22 -0500 Subject: [PATCH 1/2] add node tests for `gettid()` & `pthread_self()` --- perf-regression/node-microbench.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/perf-regression/node-microbench.c b/perf-regression/node-microbench.c index 548d82f..75ff3fc 100644 --- a/perf-regression/node-microbench.c +++ b/perf-regression/node-microbench.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,7 @@ #ifdef HAVE_ABT_H #include #endif +#include #include @@ -63,6 +65,8 @@ static void test_abt_eventual_dynamic_allocation(long unsigned iters); static void test_abt_eventual_static_allocation(long unsigned iters); #endif #endif +static void test_pthread_self(long unsigned iters); +static void test_gettid(long unsigned iters); static struct options g_opts; static struct test_case g_test_cases[] = { @@ -88,6 +92,8 @@ static struct test_case g_test_cases[] = { {"ABT_eventual static per fn", test_abt_eventual_static_allocation}, #endif #endif + {"pthread_self", test_pthread_self}, + {"gettid", test_gettid}, {NULL, NULL}}; int main(int argc, char** argv) @@ -426,3 +432,23 @@ static void test_abt_eventual_static_allocation(long unsigned iters) #endif /* ABT_EVENTUAL_INITIALIZER */ #endif /* HAVE_ABT_H */ + +/* how expensive is pthread_self()? */ +static void test_pthread_self(long unsigned iters) +{ + long unsigned i; + + for (i = 0; i < iters; i++) { pthread_self(); } + + return; +} + +/* how expensive is the gettid syscall? */ +static void test_gettid(long unsigned iters) +{ + long unsigned i; + + for (i = 0; i < iters; i++) { gettid(); } + + return; +} From 88906261cad7a59d3816e23188e2b8642337ecb4 Mon Sep 17 00:00:00 2001 From: Shane Snyder Date: Mon, 18 Mar 2024 15:27:21 -0500 Subject: [PATCH 2/2] fix comment --- perf-regression/node-microbench.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perf-regression/node-microbench.c b/perf-regression/node-microbench.c index 75ff3fc..da96de3 100644 --- a/perf-regression/node-microbench.c +++ b/perf-regression/node-microbench.c @@ -443,7 +443,7 @@ static void test_pthread_self(long unsigned iters) return; } -/* how expensive is the gettid syscall? */ +/* how expensive is gettid()? */ static void test_gettid(long unsigned iters) { long unsigned i;