Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benchmark: fix benchmark for reflink #469

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions tests/benchmarks/test_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,39 @@
import pytest
from dvc_objects.fs import localfs
from dvc_objects.fs.generic import test_links as _test_links
from pathlib import Path
from tempfile import TemporaryDirectory

from dvc_data.cli import build, gentree, get_odb
from dvc_data.hashfile.checkout import checkout
from dvc_data.hashfile.state import State


@pytest.mark.parametrize("link", ["reflink", "copy", "symlink", "hardlink"])
def test_checkout(tmp_local_path, benchmark, link):
(tmp_local_path / ".dvc").mkdir()
@pytest.fixture
def repo(request, monkeypatch):
"""Create a dvc data repo within pytest'scache directory.
The cache directory by default, is in the root of the repo, where reflink
may be supported.
"""
cache = request.config.cache
path = cache.mkdir("dvc_data_repo")
with TemporaryDirectory(dir=path) as tmp_dir:
monkeypatch.chdir(tmp_dir)
path = Path(tmp_dir)
(path / ".dvc").mkdir()
yield path


fs_path = fspath(tmp_local_path / "dataset")
@pytest.mark.parametrize("link", ["reflink", "copy", "symlink", "hardlink"])
def test_checkout(repo, benchmark, link):
fs_path = fspath(repo / "dataset")
odb = get_odb(type=[link])

if not _test_links([link], localfs, odb.path, localfs, fs_path):
pytest.skip(f"unsupported link type: {link}")

gentree(tmp_local_path / "dataset", 1000, "50Mb")
obj = build(tmp_local_path / "dataset", write=True)
gentree(repo / "dataset", 1000, "50Mb")
obj = build(repo / "dataset", write=True)
state = odb.state

def setup():
Expand All @@ -37,5 +52,6 @@ def setup():
setup=setup,
args=(fs_path, localfs, obj, odb),
kwargs={"state": state},
rounds=5,
rounds=10,
warmup_rounds=2,
)
Loading