add benchmark for item attribute / dict access

Author: @RonnyPfannschmidt in PR #5763
This commit is contained in:
Thomas Waldmann 2022-09-28 22:18:23 +02:00
parent 57ca9f6e74
commit 7b3cdb1aea

View file

@ -11,6 +11,7 @@ import os
import pytest
from .archiver import changedir, cmd
from .item import Item
from ..constants import zeros
@ -108,3 +109,17 @@ def test_check(benchmark, cmd, repo_archive):
def test_help(benchmark, cmd):
result, out = benchmark(cmd, "help")
assert result == 0
@pytest.mark.parametrize("type, key, value", [(Item, "size", 1000), (Item, "mode", 0x777), (Item, "deleted", False)])
def test_propdict_attributes(benchmark, type, key, value):
propdict = type()
def getattr_setattr(item, key, value):
setattr(item, key, value)
assert item.get(key) == value
assert getattr(item, key) == value
item.as_dict()
benchmark(getattr_setattr, propdict, key, value)