Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add sprintf benchmark.
Tests position and non-positional arguments with two
test string.
  • Loading branch information
Carlos O'Donell committed May 21, 2015
1 parent 2212c14 commit 608f897
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
7 changes: 7 additions & 0 deletions 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]
Expand Down
4 changes: 3 additions & 1 deletion benchtests/Makefile
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions 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
6 changes: 6 additions & 0 deletions 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];

0 comments on commit 608f897

Please sign in to comment.