Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ HookBase class
Runner class
------------

.. 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)
.. class:: Runner(values=3, warmups=None, processes=20, loops=0, min_time=0.1, metadata=None, show_name=True, program_args=None, add_cmdline_args=None, hooks=None)

Tool to run a benchmark in text mode.

Expand Down
4 changes: 2 additions & 2 deletions doc/runner.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Default without JIT (ex: CPython): 20 processes, 3 values per process (total: 60
values), and 1 warmup.

Default with a JIT (ex: PyPy): 6 processes, 10 values per process (total: 60
values), and 10 warmups.
values), and automatic warmup calibration.

* ``--rigorous``: Spend longer running tests to get more accurate results.
Multiply the number of ``PROCESSES`` by 2. Default: 40 processes and 3
Expand All @@ -35,7 +35,7 @@ values), and 10 warmups.
* ``VALUES``: number of values per process
(default: ``3``, or ``10`` with a JIT)
* ``WARMUPS``: the number of ignored values used to warmup to benchmark
(default: ``1``, or ``10`` with a JIT)
(default: ``1``, or automatically calibrated with a JIT)
* ``LOOPS``: number of loops per value. ``x^y`` syntax is accepted, example:
``--loops=2^8`` uses ``256`` iterations. By default, the timer is calibrated
to get raw values taking at least ``MIN_TIME`` seconds.
Expand Down
2 changes: 1 addition & 1 deletion pyperf/_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(self, values=None, processes=None,
loops=0, min_time=0.1, metadata=None,
show_name=True,
program_args=None, add_cmdline_args=None,
_argparser=None, warmups=1, hooks=None):
_argparser=None, warmups=None, hooks=None):

# Watchdog: ensure that only once instance of Runner (or a Runner
# subclass) is created per process to prevent bad surprises
Expand Down
15 changes: 15 additions & 0 deletions pyperf/tests/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ def test_debug_single_value(self):
result = self.exec_runner('--debug-single-value', '--worker')
self.assertEqual(result.bench.get_nvalue(), 1)

def test_default_warmups_without_jit(self):
with mock.patch('pyperf.python_has_jit', return_value=False):
runner = self.create_runner([])
self.assertEqual(runner.args.warmups, 1)

def test_default_warmups_with_jit(self):
with mock.patch('pyperf.python_has_jit', return_value=True):
runner = self.create_runner([])
self.assertIsNone(runner.args.warmups)

def test_runner_warmups_argument(self):
with mock.patch('pyperf.python_has_jit', return_value=True):
runner = self.create_runner([], warmups=5)
self.assertEqual(runner.args.warmups, 5)

def test_profile_time_func(self):
with tempfile.NamedTemporaryFile('wb+') as tmp:
name = tmp.name
Expand Down
Loading