Skip to content

Commit 3d9d462

Browse files
committed
Update README and benchmarks
1 parent 776b8de commit 3d9d462

3 files changed

Lines changed: 32 additions & 18 deletions

File tree

README.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ Since the performance of some variants (especially `simple`) is not great, we ru
3232

3333
See the table below for a runtime comparison of the variants that has been created with the scripts inside the `benchmark` directory. The C reference implementation serves as a comparison.
3434

35+
> [!TIP]
36+
> If the table is hard to read on the landing page, you might wanna read the README directly here: [click](README.md)
37+
38+
| variant | method | runtime (internal) | factor | runtime (total) | factor |
39+
|--------------|-------------|----------------------|---------------------|----------------------|---------------------|
40+
| reference | Gauß-Seidel | (0.5626 ± 0.0063) s | (1.0000 ± 0.0159) | (0.5640 ± 0.0061) s | (1.0000 ± 0.0154) |
41+
| reference | Jacobi | (0.4921 ± 0.0032) s | (1.0000 ± 0.0091) | (0.4939 ± 0.0031) s | (1.0000 ± 0.0089) |
42+
| simple | Gauß-Seidel | (58.9728 ± 0.0725) s | (104.8218 ± 1.1836) | (59.1671 ± 0.0721) s | (104.9124 ± 1.1500) |
43+
| simple | Jacobi | (59.9409 ± 0.2698) s | (121.7980 ± 0.9576) | (60.1439 ± 0.2765) s | (121.7734 ± 0.9513) |
44+
| nuitka | Gauß-Seidel | (56.1754 ± 0.7793) s | (99.8496 ± 1.7818) | (56.3520 ± 0.7951) s | (99.9208 ± 1.7811) |
45+
| nuitka | Jacobi | (58.2192 ± 1.7328) s | (118.2996 ± 3.6026) | (58.3895 ± 1.7231) s | (118.2213 ± 3.5678) |
46+
| np_vectorize | Gauß-Seidel | (60.2394 ± 1.2457) s | (107.0732 ± 2.5194) | (60.4389 ± 1.2378) s | (107.1674 ± 2.4860) |
47+
| np_vectorize | Jacobi | (0.3656 ± 0.0018) s | (0.7429 ± 0.0060) | (0.5601 ± 0.0025) s | (1.1340 ± 0.0088) |
48+
| numba | Gauß-Seidel | (1.1685 ± 0.0039) s | (2.0770 ± 0.0243) | (1.5011 ± 0.0153) s | (2.6617 ± 0.0397) |
49+
| numba | Jacobi | (1.1692 ± 0.0116) s | (2.3758 ± 0.0281) | (1.5184 ± 0.0254) s | (3.0743 ± 0.0549) |
50+
| cython | Gauß-Seidel | (0.5207 ± 0.0086) s | (0.9256 ± 0.0185) | (0.7169 ± 0.0094) s | (1.2712 ± 0.0217) |
51+
| cython | Jacobi | (0.5208 ± 0.0077) s | (1.0583 ± 0.0171) | (0.7197 ± 0.0160) s | (1.4571 ± 0.0337) |
52+
3553
For all benchmarks, the arguments `1 {1,2} 100 2 2 100` were used. Therefore, this only serves to give you a rough overview.
3654

3755
`runtime_internal` shows the runtime that partdiff measured itself (the `Calculation time` field in the output) and `runtime_total` shows the runtime measured via `time.perf_counter()`.
@@ -51,20 +69,7 @@ The `numba` variant performs a bit worse than the reference implementation, the
5169

5270
Finally, the performance of the `cython` variant is nearly identical to the reference implementation. Also not surprising, since the Cython code is an almost straight port of the C code, and Cython then translates that back to C and compiles it with exactly the same optimizations that the C version uses by default.
5371

54-
| variant | method | runtime_internal | | runtime_total | |
55-
|--------------|-------------|----------------------|-------------------------|----------------------|----------------------|
56-
| reference | Gauß-Seidel | (0.5626 ± 0.0063) s | (1.0000 ± 0.0159) | (0.5640 ± 0.0061) s | (1.0000 ± 0.0154) |
57-
| reference | Jacobi | (0.4921 ± 0.0032) s | (1.0000 ± 0.0091) | (0.4939 ± 0.0031) s | (1.0000 ± 0.0089) |
58-
| simple | Gauß-Seidel | (58.9728 ± 0.0725) s | (104.8218 ± 1.1836) | (59.1671 ± 0.0721) s | (104.9124 ± 1.1500) |
59-
| simple | Jacobi | (59.9409 ± 0.2698) s | (121.7980 ± 0.9576) | (60.1439 ± 0.2765) s | (121.7734 ± 0.9513) |
60-
| nuitka | Gauß-Seidel | (56.1754 ± 0.7793) s | (99.8496 ± 1.7818) | (56.3520 ± 0.7951) s | (99.9208 ± 1.7811) |
61-
| nuitka | Jacobi | (58.2192 ± 1.7328) s | (118.2996 ± 3.6026) | (58.3895 ± 1.7231) s | (118.2213 ± 3.5678) |
62-
| np_vectorize | Gauß-Seidel | (60.2394 ± 1.2457) s | (107.0732 ± 2.5194) | (60.4389 ± 1.2378) s | (107.1674 ± 2.4860) |
63-
| np_vectorize | Jacobi | (0.3656 ± 0.0018) s | (0.7429 ± 0.0060) | (0.5601 ± 0.0025) s | (1.1340 ± 0.0088) |
64-
| numba | Gauß-Seidel | (1.1685 ± 0.0039) s | (2.0770 ± 0.0243) | (1.5011 ± 0.0153) s | (2.6617 ± 0.0397) |
65-
| numba | Jacobi | (1.1692 ± 0.0116) s | (2.3758 ± 0.0281) | (1.5184 ± 0.0254) s | (3.0743 ± 0.0549) |
66-
| cython | Gauß-Seidel | (0.5207 ± 0.0086) s | (0.9256 ± 0.0185) | (0.7169 ± 0.0094) s | (1.2712 ± 0.0217) |
67-
| cython | Jacobi | (0.5208 ± 0.0077) s | (1.0583 ± 0.0171) | (0.7197 ± 0.0160) s | (1.4571 ± 0.0337) |
72+
6873

6974
## Conclusion
7075

benchmark/benchmark.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
OUTPUT_FILE = Path("benchmark_results.csv").resolve()
1515

16+
1617
@dataclass(frozen=True)
1718
class Variant:
1819
path: Path

benchmark/make_table.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ def format_ufloat_from_list(x, unit: str = None) -> str:
7676
if unit is not None:
7777
s += f" {unit}"
7878
return s
79-
80-
8179

8280
df = df.with_columns(
8381
pl.col("runtime_internal").map_elements(
@@ -103,15 +101,25 @@ def format_ufloat_from_list(x, unit: str = None) -> str:
103101
pl.col("runtime_total_factor"),
104102
)
105103

104+
df.columns = (
105+
"variant",
106+
"method",
107+
"runtime (internal)",
108+
"factor1",
109+
"runtime (total)",
110+
"factor2",
111+
)
112+
106113
with pl.Config(
107114
tbl_formatting="MARKDOWN",
108115
tbl_hide_column_data_types=True,
109116
tbl_hide_dataframe_shape=True,
110117
tbl_rows=-1,
111118
):
112119
s = str(df)
113-
for col in ("runtime_internal_factor", "runtime_total_factor"):
114-
s = s.replace(col, " " * len(col))
120+
121+
for col in ("factor1", "factor2"):
122+
s = s.replace(col, "{:{}s}".format("factor", len(col)))
115123
print(s)
116124

117125

0 commit comments

Comments
 (0)