Add a benchmark for qute:history

This commit is contained in:
Florian Bruhin 2017-02-09 21:56:06 +01:00 committed by Imran Sobir
parent 46c02bf5ae
commit f063d4be6f
3 changed files with 20 additions and 0 deletions

View File

@ -19,6 +19,7 @@ parse-type==0.3.4
py==1.4.32 py==1.4.32
pytest==3.0.6 pytest==3.0.6
pytest-bdd==2.18.1 pytest-bdd==2.18.1
pytest-benchmark==3.0.0
pytest-catchlog==1.2.2 pytest-catchlog==1.2.2
pytest-cov==2.4.0 pytest-cov==2.4.0
pytest-faulthandler==1.3.1 pytest-faulthandler==1.3.1

View File

@ -6,6 +6,7 @@ httpbin
hypothesis hypothesis
pytest pytest
pytest-bdd pytest-bdd
pytest-benchmark
pytest-catchlog pytest-catchlog
pytest-cov pytest-cov
pytest-faulthandler pytest-faulthandler

View File

@ -119,3 +119,21 @@ class TestHistoryHandler:
dates.tomorrow.strftime("%Y-%m-%d")) dates.tomorrow.strftime("%Y-%m-%d"))
_mimetype, data = qutescheme.qute_history(url) _mimetype, data = qutescheme.qute_history(url)
assert "Next" not in data assert "Next" not in data
def test_qute_history_benchmark(self, dates, entries, fake_web_history,
benchmark):
for i in range(100000):
entry = history.Entry(
atime=str(dates.yesterday.timestamp()),
url=QUrl('www.yesterday.com/{}'.format(i)),
title='yesterday')
fake_web_history._add_entry(entry)
fake_web_history._add_entry(entries.today)
fake_web_history._add_entry(entries.tomorrow)
url = QUrl("qute://history")
_mimetype, data = benchmark(qutescheme.qute_history, url)
assert "today" in data
assert "tomorrow" not in data
assert "yesterday" not in data