2 Copyright (C) 2024-2025 Free Software Foundation, Inc.
3 Copyright The GNU Toolchain Authors.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
23 #include "bench-timing.h"
26 #define NUM_FILES 1000000
27 #define NUM_FCLOSE 100
30 main (int argc
, char **argv
)
33 json_init (&json_ctx
, 0, stdout
);
34 json_document_begin (&json_ctx
);
36 json_attr_string (&json_ctx
, "timing_type", TIMING_TYPE
);
37 json_attr_object_begin (&json_ctx
, "functions");
38 json_attr_object_begin (&json_ctx
, "fclose");
40 FILE *ff
, *keep
[NUM_FCLOSE
];
43 for (i
= 0; i
< NUM_FILES
; i
++)
45 ff
= fdopen (STDIN_FILENO
, "r");
48 fprintf (stderr
, "### failed to fdopen: %m\n");
55 timing_t start
, stop
, elapsed
;
59 for (i
= 0; i
< NUM_FCLOSE
; i
++)
64 TIMING_DIFF (elapsed
, start
, stop
);
66 json_attr_uint (&json_ctx
, "number of FILEs", NUM_FILES
);
67 json_attr_uint (&json_ctx
, "number of fclose calls", NUM_FCLOSE
);
68 json_attr_uint (&json_ctx
, "duration", elapsed
);
70 json_attr_object_end (&json_ctx
);
71 json_attr_object_end (&json_ctx
);
72 json_document_end (&json_ctx
);