@@ -485,10 +485,39 @@ BenchmarkSuite class
485485 It can be ``None ``.
486486
487487
488+ HookBase class
489+ --------------
490+
491+ .. class :: HookBase()
492+
493+ Hook used to do some actions before and after benchmark's run. It can collect
494+ statistics, run external tools.
495+
496+ Methods:
497+
498+ .. method :: __enter__()
499+
500+ Called immediately before runnig benchmark code.
501+
502+ May be called multiple times per instance.
503+
504+ .. method :: __exit__(exc_type, exc_value, traceback):
505+
506+ Called immediately after running benchmark code.
507+
508+ May be called multiple times per instance.
509+
510+ .. method :: teardown(metadata)
511+
512+ Called when the hook is completed for a process.
513+
514+ May add any information collected to the passed-in ``metadata `` dictionary.
515+
516+
488517Runner class
489518------------
490519
491- .. class :: Runner(values=3, warmups=1, processes=20, loops=0, min_time=0.1, metadata=None, show_name=True, program_args=None, add_cmdline_args=None)
520+ .. class :: Runner(values=3, warmups=1, processes=20, loops=0, min_time=0.1, metadata=None, show_name=True, program_args=None, add_cmdline_args=None, hooks=None )
492521
493522 Tool to run a benchmark in text mode.
494523
@@ -512,6 +541,10 @@ Runner class
512541 (``list ``) which must be modified in place and *args * is the :attr: `args `
513542 attribute of the runner.
514543
544+ *hooks * is a list or tuple of custom hooks. Each hook should implement
545+ :class: `HookBase ` and have ``name `` attribute and ``load() `` method that
546+ returns instance of the hook.
547+
515548 If *show_name * is true, displays the benchmark name.
516549
517550 If isolated CPUs are detected, the CPU affinity is automatically
0 commit comments