ifeq (${BENCHSET},)
bench-malloc := \
+ calloc-simple \
+ calloc-thread \
malloc-simple \
malloc-thread \
# bench-malloc
else
bench-malloc := $(filter malloc-%,${BENCHSET})
+bench-malloc += $(filter calloc-%,${BENCHSET})
endif
ifeq (${STATIC-BENCHTESTS},yes)
bench-math \
bench-pthread \
bench-string \
+ calloc-simple \
+ calloc-thread \
hash-benchset \
malloc-simple \
malloc-thread \
bench-malloc: $(binaries-bench-malloc)
for run in $^; do \
echo "$${run}"; \
- if [ `basename $${run}` = "bench-malloc-thread" ]; then \
+ if [[ `basename $${run}` =~ bench-[cm]alloc-thread ]]; then \
for thr in 1 8 16 32; do \
echo "Running $${run} $${thr}"; \
$(run-bench) $${thr} > $${run}-$${thr}.out; \
--- /dev/null
+/* Benchmark calloc and free functions.
+ Copyright (C) 2024 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
+ <https://www.gnu.org/licenses/>. */
+
+#define TEST_FUNC(size) calloc (1, size)
+#define TEST_NAME "calloc"
+
+#include "bench-malloc-simple.c"
--- /dev/null
+/* Benchmark calloc and free functions.
+ Copyright (C) 2024 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
+ <https://www.gnu.org/licenses/>. */
+
+#define TEST_FUNC(size) calloc (1, size)
+#define TEST_NAME "calloc"
+
+#include "bench-malloc-thread.c"
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+#ifndef TEST_FUNC
+# define TEST_FUNC(size) malloc(size)
+# define TEST_NAME "malloc"
+#endif
+
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
for (int j = 0; j < iters; j++)
{
for (int i = 0; i < n; i++)
- arr[i] = malloc (size);
+ arr[i] = TEST_FUNC (size);
for (int i = 0; i < n; i++)
free (arr[i]);
json_attr_object_begin (&json_ctx, "functions");
- json_attr_object_begin (&json_ctx, "malloc");
+ json_attr_object_begin (&json_ctx, TEST_NAME);
char s[100];
double iters2 = iters;
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+#ifndef TEST_FUNC
+# define TEST_FUNC(size) malloc(size)
+# define TEST_NAME "malloc"
+#endif
+
#include <errno.h>
#include <math.h>
#include <pthread.h>
free (ptr_arr[next_idx]);
- ptr_arr[next_idx] = malloc (next_block);
+ ptr_arr[next_idx] = TEST_FUNC (next_block);
iters++;
}
json_attr_object_begin (&json_ctx, "functions");
- json_attr_object_begin (&json_ctx, "malloc");
+ json_attr_object_begin (&json_ctx, TEST_NAME);
json_attr_object_begin (&json_ctx, "");