aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos O'Donell <carlos@systemhalted.org>2015-05-21 10:01:34 -0400
committerCarlos O'Donell <carlos@systemhalted.org>2015-05-21 10:02:52 -0400
commit608f897106eb10d3b250fae88478b3b1ac3999d5 (patch)
tree60c56f5149287bc597771ed8a57ff47d25ed9d3f
parent2212c1420c92a33b0e0bd9a34938c9814a56c0f7 (diff)
downloadglibc-608f897106eb10d3b250fae88478b3b1ac3999d5.zip
glibc-608f897106eb10d3b250fae88478b3b1ac3999d5.tar.gz
glibc-608f897106eb10d3b250fae88478b3b1ac3999d5.tar.bz2
Add sprintf benchmark.
Tests position and non-positional arguments with two test string.
-rw-r--r--ChangeLog7
-rw-r--r--benchtests/Makefile4
-rw-r--r--benchtests/sprintf-inputs10
-rw-r--r--benchtests/sprintf-source.c6
4 files changed, 26 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index ce056a4..025bac1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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.
+
2015-05-21 Andreas Schwab <schwab@suse.de>
[BZ #13028]
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..29ea6c6
--- /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];