Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Siddhesh Poyarekar committed May 26, 2014
1 parent 75f1133 commit 15eaf6f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ChangeLog
@@ -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]
Expand Down
1 change: 1 addition & 0 deletions benchtests/README
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions benchtests/bench-skeleton.c
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion benchtests/scripts/bench.py
Expand Up @@ -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})


Expand Down Expand Up @@ -232,7 +236,8 @@ def parse_file(func):
'args': [],
'includes': [],
'include-sources': [],
'ret': ''
'ret': '',
'init': ''
}

try:
Expand Down

0 comments on commit 15eaf6f

Please sign in to comment.