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

misc: optimize by avoiding repetitive code #59

Closed
Closed
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions testcases/misc/test_dbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ def _check_dbm_consistency(base: Path, nrecs: int) -> None:
def _run_dbm_consistency_checks(base_path: Path) -> None:
base_path.mkdir(parents=True, exist_ok=True)
try:
_check_dbm_consistency(base_path, 10)
_check_dbm_consistency(base_path, 100)
_check_dbm_consistency(base_path, 10000)
test_sizes = [10, 100, 10000]

for size in test_sizes:
_check_dbm_consistency(base_path, size)
finally:
shutil.rmtree(base_path, ignore_errors=True)

Expand Down
20 changes: 11 additions & 9 deletions testcases/misc/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,19 @@ def _run_checks(dsets: typing.List[DataPath]) -> None:
def _check_io_consistency(test_dir: Path) -> None:
base = None
try:
print("\n")
base = test_dir / "test_io_consistency"
base.mkdir(parents=True)
# Case-1: single 4K file
_run_checks(_make_datasets(base, 4096, 1))
# Case-2: single 16M file
_run_checks(_make_datasets(base, 2**24, 1))
# Case-3: few 1M files
_run_checks(_make_datasets(base, 2**20, 10))
# Case-4: many 1K files
_run_checks(_make_datasets(base, 1024, 100))

test_cases = [
(4096, 1), # Case-1: single 4K file
(2**24, 1), # Case-2: single 16M file
(2**20, 10), # Case-3: few 1M files
(1024, 100), # Case-4: many 1K files
]

for size, count in test_cases:
datasets = _make_datasets(base, size, count)
_run_checks(datasets)
except Exception as ex:
print("Error while executing test_io_consistency: %s", ex)
raise
Expand Down