diff options
| author | Wangyang Guo <wangyang.guo@intel.com> | 2024-11-29 16:05:35 +0800 |
|---|---|---|
| committer | H.J. Lu <hjl.tools@gmail.com> | 2024-11-29 19:04:28 +0800 |
| commit | 2d6427a63cad8056ba6bcaaaa8df21977c8dde3d (patch) | |
| tree | 0af48fd8aa244a5193202a5ebe59e58a1e0e1f37 /benchtests/bench-malloc-simple.c | |
| parent | 19a198f05802fcc05441c364ed75311ef3f6d663 (diff) | |
| download | glibc-2d6427a63cad8056ba6bcaaaa8df21977c8dde3d.tar.xz glibc-2d6427a63cad8056ba6bcaaaa8df21977c8dde3d.zip | |
benchtests: Add calloc test
Two new benchmarks related to calloc added:
- bench-calloc-simple
- bench-calloc-thread
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Diffstat (limited to 'benchtests/bench-malloc-simple.c')
| -rw-r--r-- | benchtests/bench-malloc-simple.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/benchtests/bench-malloc-simple.c b/benchtests/bench-malloc-simple.c index 289bb660ad..2af52ae6b8 100644 --- a/benchtests/bench-malloc-simple.c +++ b/benchtests/bench-malloc-simple.c @@ -16,6 +16,11 @@ 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> @@ -55,7 +60,7 @@ do_benchmark (malloc_args *args, int **arr) 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]); @@ -124,7 +129,7 @@ bench (unsigned long size) 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; |
