-
-
Save altendky/ba532000a306b658c25d9fe899565f79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ venv/bin/python x.py | |
Repeats interleaved: True | |
100% standard_model.data(standard_index, 0) : 0.0008812999876681715 | |
142% python_model.data(python_index, 0) : 0.0012507610081229359 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import altendpy.timeit | |
import PyQt5.QtGui | |
import PyQt5.QtWidgets | |
class PyQStandardItemModel(PyQt5.QtGui.QStandardItemModel): | |
def data(self, index, role): | |
return super().data(index, role) | |
application = PyQt5.QtWidgets.QApplication([]) | |
setup = '''\ | |
from {} import python_model, standard_model, python_index, standard_index | |
'''.format(__name__) | |
python_model = PyQStandardItemModel() | |
standard_model = PyQt5.QtGui.QStandardItemModel() | |
python_item = PyQt5.QtGui.QStandardItem() | |
python_item.setText("abcdef") | |
python_model.appendRow(python_item) | |
python_index = python_model.indexFromItem(python_item) | |
standard_item = PyQt5.QtGui.QStandardItem() | |
standard_item.setText("abcdef") | |
standard_model.appendRow(standard_item) | |
standard_index = standard_model.indexFromItem(standard_item) | |
def main(): | |
runner = altendpy.timeit.Runner( | |
examples=( | |
altendpy.timeit.Example(statement="python_model.data(python_index, 0)"), | |
altendpy.timeit.Example(statement="standard_model.data(standard_index, 0)"), | |
), | |
repeats=10000, | |
interleave=True, | |
cycles=1000, | |
setup=setup, | |
) | |
runner.run() | |
print(runner.tabulate()) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment