Skip to content

Commit efeedc2

Browse files
authored
Merge pull request #395 from JamesParrott/_HasExitStack_and__FileChecker_base_classes
Has exit stack and file checker base classes
2 parents eccacf9 + c55fbee commit efeedc2

2 files changed

Lines changed: 266 additions & 142 deletions

File tree

run_benchmarks.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,14 @@ def write_shapefile_with_PyShp(target: str | PathLike):
8585
for file_path in SHAPEFILES.values():
8686
file_path.read_bytes()
8787

88+
COLS_WIDTHS = (22, 10)
89+
8890
reader_benchmarks = [
8991
functools.partial(
9092
benchmark,
9193
name=f"Read {test_name}",
9294
func=functools.partial(open_shapefile_with_PyShp, target=target),
95+
col_widths=COLS_WIDTHS,
9396
)
9497
for test_name, target in SHAPEFILES.items()
9598
]
@@ -101,13 +104,17 @@ def write_shapefile_with_PyShp(target: str | PathLike):
101104
benchmark,
102105
name=f"Write {test_name}",
103106
func=functools.partial(write_shapefile_with_PyShp, target=target),
107+
col_widths=COLS_WIDTHS,
104108
)
105109
for test_name, target in SHAPEFILES.items()
106110
]
107111

108112

109-
def run(run_count: int, benchmarks: list[Callable[[], None]]) -> None:
110-
col_widths = (22, 10)
113+
def run(
114+
run_count: int,
115+
benchmarks: list[Callable[[], None]],
116+
col_widths: tuple[int, int] = COLS_WIDTHS,
117+
) -> None:
111118
col_head = ("parser", "exec time", "performance (more is better)")
112119
print(f"Running benchmarks {run_count} times:")
113120
print("-" * col_widths[0] + "---" + "-" * col_widths[1])
@@ -116,7 +123,6 @@ def run(run_count: int, benchmarks: list[Callable[[], None]]) -> None:
116123
for benchmark in benchmarks:
117124
benchmark( # type: ignore [call-arg]
118125
run_count=run_count,
119-
col_widths=col_widths,
120126
)
121127

122128

0 commit comments

Comments
 (0)