mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-05 14:52:30 -04:00
add benchmark for item attribute / dict access
Author: @RonnyPfannschmidt in PR #5763
This commit is contained in:
parent
57ca9f6e74
commit
7b3cdb1aea
1 changed files with 15 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue