This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 5/6] vfprintf: Introduce printf_positional function
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: Florian Weimer <fweimer at redhat dot com>, libc-alpha at sourceware dot org
- Date: Thu, 21 May 2015 00:55:19 -0400
- Subject: Re: [PATCH 5/6] vfprintf: Introduce printf_positional function
- Authentication-results: sourceware.org; auth=none
- References: <cover dot 1425246936 dot git dot fweimer at redhat dot com> <06448920c54ddf7d92cce8a2311a0daf470436aa dot 1425246936 dot git dot fweimer at redhat dot com> <54F9A453 dot 5060506 at redhat dot com> <555D53A1 dot 60604 at redhat dot com> <20150521041605 dot GL15498 at spoyarek dot pnq dot redhat dot com>
On 05/21/2015 12:16 AM, Siddhesh Poyarekar wrote:
> 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:
Oh! You're saying that the performance domain of positional versus
non-positional is different and should not be lumped together, as
Florian did not lump them together in his analysis.
v2
- Split out positional vs non-positional.
Test run:
"sprintf": {
"positional": {
"duration": 3.49965e+10,
"iterations": 1.7381e+07,
"max": 2733.1,
"min": 2007.32,
"mean": 2013.49
},
"non-positional": {
"duration": 3.49927e+10,
"iterations": 2.8668e+07,
"max": 1379.96,
"min": 1214.8,
"mean": 1220.62
}
}
2015-05-21 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..9a7710d
--- /dev/null
+++ b/benchtests/sprintf-inputs
@@ -0,0 +1,10 @@
+## 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
+## name: positional
+# Test positional arguments:
+buf, FORMAT1, 1001, '1', '2', '3', '4', '5', "string", 1.5, 0x1234
+## name: non-positional
+# Test non-positional arguments:
+buf, FORMAT2, 1001, '1', '2', '3', '4', '5', "string", 1.5, 0x1234
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, set of non-positional format specifiers. */
+#define FORMAT2 " %d: %c%c%c%c%c %20s %f (%02x)\n"
+/* Sufficiently large buffer. */
+char buf[256];
---
Cheers,
Carlos.