diff options
author | Siddhesh Poyarekar <siddhesh@redhat.com> | 2014-02-22 10:09:27 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@redhat.com> | 2014-05-26 12:37:29 +0530 |
commit | 15eaf6ffe3e117684a0e7b070c0a8754480d3fa3 (patch) | |
tree | fb9f01290abc80717a41e623699dfec063c1b0df | |
parent | 75f11331f98ebf3873e887a683add944a1aec0fd (diff) | |
download | glibc-15eaf6ffe3e117684a0e7b070c0a8754480d3fa3.tar glibc-15eaf6ffe3e117684a0e7b070c0a8754480d3fa3.tar.gz glibc-15eaf6ffe3e117684a0e7b070c0a8754480d3fa3.tar.bz2 glibc-15eaf6ffe3e117684a0e7b070c0a8754480d3fa3.zip |
benchtests: Add new directive for benchmark initialization hook
Add a new 'init' directive that specifies the name of the function to
call to do function-specific initialization. This is useful for
benchmarks that need to do a one-time initialization before the
functions are executed.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | benchtests/README | 1 | ||||
-rw-r--r-- | benchtests/bench-skeleton.c | 3 | ||||
-rwxr-xr-x | benchtests/scripts/bench.py | 7 |
4 files changed, 18 insertions, 1 deletions
@@ -1,3 +1,11 @@ +2014-05-26 Siddhesh Poyarekar <siddhesh@redhat.com> + + * benchtests/README: Document 'init' directive. + * benchtests/bench-skeleton.c (main) [BENCH_INIT]: Call + BENCH_INIT. + * scripts/bench.py (gen_source): Define BENCH_INIT macro. + (parse_file): Recognize 'init' directive. + 2014-05-26 Kyle McMartin <kyle@redhat.com> [BZ #16796] diff --git a/benchtests/README b/benchtests/README index 52a3cc2062..999d268cf8 100644 --- a/benchtests/README +++ b/benchtests/README @@ -62,6 +62,7 @@ one to add `foo' to the bench tests: and functions (specifically, this includes using "#include "source"). See pthread_once-inputs and pthreads_once-source.c for an example of how to use this to benchmark a function that needs state across several calls. + - init: Name of an initializer function to call to initialize the benchtest. - name: See following section for instructions on how to use this directive. Lines beginning with a single hash '#' are treated as comments. See diff --git a/benchtests/bench-skeleton.c b/benchtests/bench-skeleton.c index 29d6bda809..68a91dcc7a 100644 --- a/benchtests/bench-skeleton.c +++ b/benchtests/bench-skeleton.c @@ -62,6 +62,9 @@ main (int argc, char **argv) unsigned long iters, res; +#ifdef BENCH_INIT + BENCH_INIT (); +#endif TIMING_INIT (res); iters = 1000 * res; diff --git a/benchtests/scripts/bench.py b/benchtests/scripts/bench.py index 492c764aa7..eb5a14141a 100755 --- a/benchtests/scripts/bench.py +++ b/benchtests/scripts/bench.py @@ -128,6 +128,10 @@ def gen_source(func, directives, all_vals): else: getret = '' + # Test initialization. + if directives['init']: + print('#define BENCH_INIT %s' % directives['init']) + print(EPILOGUE % {'getret': getret, 'func': func}) @@ -232,7 +236,8 @@ def parse_file(func): 'args': [], 'includes': [], 'include-sources': [], - 'ret': '' + 'ret': '', + 'init': '' } try: |