This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 5/6] vfprintf: Introduce printf_positional function


On Wed, May 20, 2015 at 11:40:17PM -0400, Carlos O'Donell wrote:
> 2015-05-20  Carlos O'Donell  <carlos@redhat.com>
> 
> 	* benchtests/Makefile (stdio-common-bench): Define.
> 	(benchset): Add stdio-common-bench.
> 	* sprintf-inputs: New file.
> 	* sprintf-source.c: New file.
> 
> diff --git a/benchtests/Makefile b/benchtests/Makefile
> index cb7a97e..8e615e5 100644
> --- a/benchtests/Makefile
> +++ b/benchtests/Makefile
> @@ -48,7 +48,9 @@ include ../gen-locales.mk
>  
>  stdlib-bench := strtod
>  
> -benchset := $(string-bench-all) $(stdlib-bench)
> +stdio-common-bench := sprintf
> +
> +benchset := $(string-bench-all) $(stdlib-bench) $(stdio-common-bench)
>  
>  CFLAGS-bench-ffs.c += -fno-builtin
>  CFLAGS-bench-ffsll.c += -fno-builtin
> diff --git a/benchtests/sprintf-inputs b/benchtests/sprintf-inputs
> new file mode 100644
> index 0000000..0e034b5
> --- /dev/null
> +++ b/benchtests/sprintf-inputs
> @@ -0,0 +1,8 @@
> +## args: char *:const char *:int:char:char:char:char:char:const char *:float:unsigned int
> +## ret: int
> +## includes: stdio.h
> +## include-sources: sprintf-source.c
> +# Test positional arguments:
> +buf, FORMAT1, 1001, '1', '2', '3', '4', '5', "string", 1.5, 0x1234
> +# Test non-positional arguments:
> +buf, FORMAT2, 1001, '1', '2', '3', '4', '5', "string", 1.5, 0x1234

You would want two different outputs for positional and non-positional
respectively to match Florian's output.  You can achieve that with the
##name directive by putting the line:

##name: positional

and

##name: nonpositional

before each of the inputs.

> diff --git a/benchtests/sprintf-source.c b/benchtests/sprintf-source.c
> new file mode 100644
> index 0000000..fc125a5
> --- /dev/null
> +++ b/benchtests/sprintf-source.c
> @@ -0,0 +1,6 @@
> +/* A set of arbitrarily selected positional format specifiers.  */
> +#define FORMAT1 "   %1$d: %2$c%3$c%4$c%5$c%6$c %7$20s %8$f (%9$02x)\n"
> +/* A matching, but arbitrarily selected, non-positional format specifiers.  */
> +#define FORMAT2 "   %d: %c%c%c%c%c %20s %f (%02x)\n"
> +/* Sufficiently large buffer.  */
> +char buf[256];
> ---
> 
> Cheers,
> Carlos.
> 

Attachment: pgp22MFBxFl_p.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]