>From 8bad3c9751cba151b5f4ad2108bf2b860705c6eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20B=C3=ADlka?= Date: Sun, 26 Jul 2015 10:15:56 +0200 Subject: [PATCH 2/4] dlopen benchmark --- benchtests/Makefile | 3 ++- benchtests/bench-dlopen.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 benchtests/bench-dlopen.c diff --git a/benchtests/Makefile b/benchtests/Makefile index 8e615e5..9e82e43 100644 --- a/benchtests/Makefile +++ b/benchtests/Makefile @@ -30,7 +30,7 @@ bench-pthread := pthread_once bench := $(bench-math) $(bench-pthread) # String function benchmarks. -string-bench := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \ +string-bench := dlopen bcopy bzero memccpy memchr memcmp memcpy memmem memmove \ mempcpy memset rawmemchr stpcpy stpncpy strcasecmp strcasestr \ strcat strchr strchrnul strcmp strcpy strcspn strlen \ strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \ @@ -57,6 +57,7 @@ CFLAGS-bench-ffsll.c += -fno-builtin bench-malloc := malloc-thread +$(objpfx)bench-dlopen: -ldl $(addprefix $(objpfx)bench-,$(bench-math)): $(libm) $(addprefix $(objpfx)bench-,$(bench-pthread)): $(shared-thread-library) $(objpfx)bench-malloc-thread: $(shared-thread-library) diff --git a/benchtests/bench-dlopen.c b/benchtests/bench-dlopen.c new file mode 100644 index 0000000..b47d18b --- /dev/null +++ b/benchtests/bench-dlopen.c @@ -0,0 +1,47 @@ +/* Measure strcpy functions. + Copyright (C) 2013-2015 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 + . */ +#include +#include +#include "bench-timing.h" + +int +main (void) +{ + long ret = 0; + + size_t i, j,iters = 100; + timing_t start, stop, cur; + for (j=0;j<10;j++) + { + TIMING_NOW (start); + for (i = 0; i < iters; ++i) + { + ret += (long) dlsym (RTLD_DEFAULT, "strlen"); + ret += (long) dlsym (RTLD_DEFAULT, "memcpy"); + } + TIMING_NOW (stop); + + TIMING_DIFF (cur, start, stop); + + TIMING_PRINT_MEAN ((double) cur, (double) iters); + } + + return ret; +} + + -- 2.1.4