Skip to content
Merged
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
12 changes: 9 additions & 3 deletions run_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ def write_shapefile_with_PyShp(target: str | PathLike):
for file_path in SHAPEFILES.values():
file_path.read_bytes()

COLS_WIDTHS = (22, 10)

reader_benchmarks = [
functools.partial(
benchmark,
name=f"Read {test_name}",
func=functools.partial(open_shapefile_with_PyShp, target=target),
col_widths=COLS_WIDTHS,
)
for test_name, target in SHAPEFILES.items()
]
Expand All @@ -101,13 +104,17 @@ def write_shapefile_with_PyShp(target: str | PathLike):
benchmark,
name=f"Write {test_name}",
func=functools.partial(write_shapefile_with_PyShp, target=target),
col_widths=COLS_WIDTHS,
)
for test_name, target in SHAPEFILES.items()
]


def run(run_count: int, benchmarks: list[Callable[[], None]]) -> None:
col_widths = (22, 10)
def run(
run_count: int,
benchmarks: list[Callable[[], None]],
col_widths: tuple[int, int] = COLS_WIDTHS,
) -> None:
col_head = ("parser", "exec time", "performance (more is better)")
print(f"Running benchmarks {run_count} times:")
print("-" * col_widths[0] + "---" + "-" * col_widths[1])
Expand All @@ -116,7 +123,6 @@ def run(run_count: int, benchmarks: list[Callable[[], None]]) -> None:
for benchmark in benchmarks:
benchmark( # type: ignore [call-arg]
run_count=run_count,
col_widths=col_widths,
)


Expand Down
Loading
Loading