From 97d719b1792e419aa53e36467d9e0186d71bbf75 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Thu, 26 Oct 2017 17:56:28 -0400 Subject: [PATCH] Add a simple benchmark for _update_tab_titles --- tests/unit/mainwindow/test_tabwidget.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/unit/mainwindow/test_tabwidget.py b/tests/unit/mainwindow/test_tabwidget.py index e05e6a164..14b35bc03 100644 --- a/tests/unit/mainwindow/test_tabwidget.py +++ b/tests/unit/mainwindow/test_tabwidget.py @@ -52,3 +52,21 @@ class TestTabWidget: with qtbot.waitExposed(widget): widget.show() + + def test_update_tab_titles_benchmark(self, benchmark, widget, + qtbot, fake_web_tab): + """Benchmark for update_tab_titles.""" + widget.addTab(fake_web_tab(), 'foobar') + widget.addTab(fake_web_tab(), 'foobar2') + widget.addTab(fake_web_tab(), 'foobar3') + widget.addTab(fake_web_tab(), 'foobar4') + + with qtbot.waitExposed(widget): + widget.show() + + def bench(): + for _a in range(1000): + # pylint: disable=protected-access + widget._update_tab_titles() + # pylint: enable=protected-access + benchmark(bench)