forked from ClickHouse/sql-mandelbrot-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
70 lines (56 loc) · 2.21 KB
/
Copy pathmain.py
File metadata and controls
70 lines (56 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
Mandelbrot Set Benchmark Suite
A comprehensive benchmark comparing different approaches to computing
the Mandelbrot set. Tests SQL engines, programming languages, and
various optimization techniques.
Author: Thomas Zeutschler
License: MIT
GitHub: https://github.com/Zeutschler/sql-mandelbrot-benchmark
"""
from utils import print_header, print_results, run_benchmark, save_mandelbrot_image
# Mandelbrot set configuration
WIDTH = 1400
HEIGHT = 800
MAX_ITERATIONS = 256
# Benchmark registry: (name, module, function)
BENCHMARKS = [
("ClickHouse (SQL)", "clickbrot", "run_clickbrot"),
("chDB (SQL)", "chbrot", "run_chbrot"),
("NumPy (Vectorized)", "numpybrot", "run_numpybrot"),
("ArrowDatafusion (SQL)", "arrow_datafusion", "run_arrow_datafusion"),
("CedarDB (SQL)", "cedarbrot", "run_cedarbrot"),
("DuckDB (SQL)", "duckbrot", "run_duckbrot"),
("Arc (SQL, HTTP+Arrow)", "arcbrot", "run_arcbrot"),
("FastPybrot", "fastpybrot", "run_pybrot"),
("FasterPybrot", "fasterpybrot", "run_pybrot"),
("Pure Python", "pybrot", "run_pybrot"),
("SQLite (SQL)", "sqlitebrot", "run_sqlitebrot"),
# Add more benchmarks here:
# ("PostgreSQL", "postgresqlbrot", "run_postgresqlbrot"),
# ("MySQL", "mysqlbrot", "run_mysqlbrot"),
]
def main():
"""Run all available benchmarks."""
print_header(WIDTH, HEIGHT, MAX_ITERATIONS)
results = []
# Run all available benchmarks
for name, module_name, func_name in BENCHMARKS:
try:
module = __import__(module_name)
func = getattr(module, func_name)
result, elapsed_ms = run_benchmark(
name, func, WIDTH, HEIGHT, MAX_ITERATIONS
)
results.append((name, elapsed_ms))
# Save the generated image
if result is not None:
filename = f"{module_name}.png"
save_mandelbrot_image(result, MAX_ITERATIONS, filename)
except ImportError as e:
print(f"\n⊘ {name} benchmark not available: {e}")
except AttributeError as e:
print(f"\n⊘ {name} benchmark missing function: {e}")
# Print summary
print_results(results, WIDTH, HEIGHT, MAX_ITERATIONS)
if __name__ == "__main__":
main()