Skip to content

Commit

Permalink
Update assertions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ionelmc committed Oct 20, 2015
1 parent 36c061b commit e6738e2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 75 deletions.
1 change: 1 addition & 0 deletions src/pytest_benchmark/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ def generate_histogram_table(current, history, sequence):
yield HISTOGRAM_CURRENT, current.json()

def display_results_table(self, tr):
tr.write_line("")
tr.rewrite("Computing stats ...", black=True, bold=True)
groups = self.config.hook.pytest_benchmark_group_stats(
config=self.config,
Expand Down
Empty file added src/pytest_benchmark/table.py
Empty file.
67 changes: 6 additions & 61 deletions tests/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,6 @@ def test_group_by_name(testdir):
result = testdir.runpytest('--benchmark-max-time=0.0000001', '--benchmark-group-by', 'name', test_x, test_y)
result.stdout.fnmatch_lines([
'*', '*', '*', '*', '*',
"Benchmark global settings:",
" minimum number of rounds: *",
" minimum time per rounds: *",
" maximum total time per test: *",
" timer: *",
"* benchmark 'test_a[[]0[]]': 2 tests *",
'Name (time in ?s) *',
'----------------------*',
Expand Down Expand Up @@ -238,32 +233,29 @@ def test_group_by_fullfunc(testdir):
'test_a[[]0[]] *',
'test_a[[]1[]] *',
'------------------*',
'(*) Outliers: 1 Standard Deviation from M*',
'*',
'',
"* benchmark 'test_x.py::test_b': 2 tests *",
'Name (time in ?s) *',
'------------------*',
'test_b[[]0[]] *',
'test_b[[]1[]] *',
'------------------*',
'(*) Outliers: 1 Standard Deviation from M*',
'*',
'',
"* benchmark 'test_y.py::test_a': 2 tests *",
'Name (time in ?s) *',
'------------------*',
'test_a[[]0[]] *',
'test_a[[]1[]] *',
'------------------*',
'(*) Outliers: 1 Standard Deviation from M*',
'*',
'',
"* benchmark 'test_y.py::test_b': 2 tests *",
'Name (time in ?s) *',
'------------------*',
'test_b[[]0[]] *',
'test_b[[]1[]] *',
'------------------*',
'',
'(*) Outliers: 1 Standard Deviation from M*',
'*',
'============* 8 passed* seconds ============*',
])

Expand All @@ -282,8 +274,6 @@ def test_group_by_param(testdir):
'test_b[[]0[]] *',
'test_b[[]0[]] *',
'-------------------*',
'(*) Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd '
'Quartile.',
'',
"* benchmark '1': 4 tests *",
'Name (time in ?s) *',
Expand All @@ -293,9 +283,9 @@ def test_group_by_param(testdir):
'test_b[[]1[]] *',
'test_b[[]1[]] *',
'------------------*',
'',
'(*) Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd '
'Quartile.',
'',
'============* 8 passed* seconds ============*',
])

Expand Down Expand Up @@ -340,11 +330,6 @@ def test_max_time_min_rounds(testdir):
result.stdout.fnmatch_lines([
"*collected 3 items",
"test_max_time_min_rounds.py ...",
"Benchmark global settings:",
" minimum number of rounds: 1",
" minimum time per rounds: 5.00us",
" maximum total time per test: 1.00us",
" timer: *",
"* benchmark: 2 tests *",
"Name (time in ?s) * Min * Max * Mean * StdDev * Rounds * Iterations",
"------*",
Expand All @@ -361,11 +346,6 @@ def test_max_time(testdir):
result.stdout.fnmatch_lines([
"*collected 3 items",
"test_max_time.py ...",
"Benchmark global settings:",
" minimum number of rounds: 5",
" minimum time per rounds: 5.00us",
" maximum total time per test: 1.00us",
" timer: *",
"* benchmark: 2 tests *",
"Name (time in ?s) * Min * Max * Mean * StdDev * Rounds * Iterations",
"------*",
Expand All @@ -391,7 +371,7 @@ def test_pep418_timer(testdir):
result = testdir.runpytest('--benchmark-max-time=0.0000001', '--doctest-modules',
'--benchmark-timer=pep418.perf_counter', test)
result.stdout.fnmatch_lines([
" timer: *.perf_counter",
"* (defaults: timer=*.perf_counter*",
])


Expand Down Expand Up @@ -573,11 +553,6 @@ def test_disable_gc(testdir):
result.stdout.fnmatch_lines([
"*collected 2 items",
"test_disable_gc.py ..",
"Benchmark global settings:",
" minimum number of rounds: *",
" minimum time per rounds: *",
" maximum total time per test: *",
" timer: *",
"* benchmark: 2 tests *",
"Name (time in ?s) * Min * Max * Mean * StdDev * Rounds * Iterations",
"------*",
Expand All @@ -594,11 +569,6 @@ def test_custom_timer(testdir):
result.stdout.fnmatch_lines([
"*collected 2 items",
"test_custom_timer.py ..",
"Benchmark global settings:",
" minimum number of rounds: *",
" minimum time per rounds: *",
" maximum total time per test: *",
" timer: *",
"* benchmark: 2 tests *",
"Name (time in ?s) * Min * Max * Mean * StdDev * Rounds * Iterations",
"------*",
Expand All @@ -625,11 +595,6 @@ def test_sort_by_mean(testdir):
result.stdout.fnmatch_lines([
"*collected 2 items",
"test_sort_by_mean.py ..",
"Benchmark global settings:",
" minimum number of rounds: *",
" minimum time per rounds: *",
" maximum total time per test: *",
" timer: *",
"* benchmark: 2 tests *",
"Name (time in ?s) * Min * Max * Mean * StdDev * Rounds * Iterations",
"------*",
Expand Down Expand Up @@ -774,11 +739,6 @@ def result():
"E assert 1 == 0",

"test_abort_broken.py:18: AssertionError",
"Benchmark global settings:",
" minimum number of rounds: *",
" minimum time per rounds: *",
" maximum total time per test: *",
" timer: *",
"* benchmark: 1 tests *",
"Name (time in ?s) * Min * Max * Mean * StdDev * Rounds * Iterations",
"------*",
Expand Down Expand Up @@ -832,11 +792,6 @@ def test_basic(testdir):
"test_basic.py::test_xfast PASSED",
"test_basic.py::test_fast PASSED",
"",
"Benchmark global settings:",
" minimum number of rounds: *",
" minimum time per rounds: *",
" maximum total time per test: *",
" timer: *",
"* benchmark: 4 tests *",
"Name (time in ?s) * Min * Max * Mean * StdDev * Rounds * Iterations",
"------*",
Expand Down Expand Up @@ -884,11 +839,6 @@ def test_mark_selection(testdir):
result.stdout.fnmatch_lines([
"*collected 5 items",
"test_mark_selection.py::test_xfast PASSED",
"Benchmark global settings:",
" minimum number of rounds: *",
" minimum time per rounds: *",
" maximum total time per test: *",
" timer: *",
"* benchmark: 1 tests *",
"Name (time in ?s) * Min * Max * Mean * StdDev * Rounds * Iterations",
"------*",
Expand All @@ -909,11 +859,6 @@ def test_only_benchmarks(testdir):
"test_only_benchmarks.py::test_slower PASSED",
"test_only_benchmarks.py::test_xfast PASSED",
"test_only_benchmarks.py::test_fast PASSED",
"Benchmark global settings:",
" minimum number of rounds: *",
" minimum time per rounds: *",
" maximum total time per test: *",
" timer: *",
"* benchmark: 4 tests *",
"Name (time in ?s) * Min * Max * Mean * StdDev * Rounds * Iterations",
"------*",
Expand Down
22 changes: 8 additions & 14 deletions tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,20 +199,17 @@ def test_compare(sess, LineMatcher):
'| commit info: {dirty: true, id: "5b78858eb718649a31fb93d8dc96ca2cee41a4cd"}',
'| saved at: 2015-08-15T00:01:46.250433',
'| saved using pytest-benchmark 2.5.0:',
'Benchmark global settings:',
' minimum number of rounds: 123',
' minimum time per rounds: 234',
' maximum total time per test: 345',
' timer: None',
'',
'*-------------------------------------------------------------------------------------- benchmark: 1 tests --------------------------------------------------------------------------------------*',
'Name (time in ns) Min *Max Mean StdDev Median IQR Outliers(*) Rounds Iterations',
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*',
'test_xfast_parametrized[[]0[]] 217.9511 13*290.0380 261.2051 263.9842 220.1638 18.8080 160;1726 9710 431',
' +0.6365 (0%) +1*842.6488 (16%) -1.0357 (0%) +49.9400 (23%) -0.0026 (0%) -19.4075 (50%) 90;1878 9987 418',
'(d)0001 +0.6365 (99%) +1,842.6488 (86%) -1.0357 (100%) +49.9400 (81%) -0.0026 (100%) -19.4075 (203%) 90;1878 9987 418',
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*',
'(*) Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.',
'',
'(d) Delta to 0001: "difference (percent%)"',
' where: difference = current - previous',
' percent = current / previous * 100 - 100 ',
])


Expand All @@ -233,20 +230,17 @@ def test_compare_2(sess, LineMatcher):
'| commit info: {dirty: true, id: "5b78858eb718649a31fb93d8dc96ca2cee41a4cd"}',
'| saved at: 2015-08-15T00:01:51.557705',
'| saved using pytest-benchmark 2.5.0:',
'Benchmark global settings:',
' minimum number of rounds: 123',
' minimum time per rounds: 234',
' maximum total time per test: 345',
' timer: None',
'',
'*-------------------------------------------------------------------------------------- benchmark: 1 tests --------------------------------------------------------------------------------------*',
'Name (time in ns) Min *Max Mean StdDev Median IQR Outliers(*) Rounds Iterations',
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*',
'test_xfast_parametrized[[]0[]] 217.9511 13*290.0380 261.2051 263.9842 220.1638 18.8080 160;1726 9710 431',
' +1.0483 (0%) +5*550.7383 (71%) +7.1466 (2%) +263.9842 (infinite%) +0.3535 (0%) -8.5229 (31%) 235;1688 11009 410',
'(d)0002 +1.0483 (99%) +5,550.7383 (58%) +7.1466 (97%) +263.9842 (0%) +0.3535 (99%) -8.5229 (145%) 235;1688 11009 410',
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*',
'(*) Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.',
''
'(d) Delta to 0002: "difference (percent%)"',
' where: difference = current - previous',
' percent = current / previous * 100 - 100 ',
])

@freeze_time("2015-08-15T00:04:18.687119")
Expand Down

0 comments on commit e6738e2

Please sign in to comment.