Created
May 4, 2025 17:43
-
-
Save IvanIsCoding/58157618e75a0c6aaf699dc5882d7829 to your computer and use it in GitHub Desktop.
rustworkx foldhash vs ahash benchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(base) ➜ minibench uv run released_rustworkx.py | |
Python version: 3.12.3 | packaged by Anaconda, Inc. | (main, May 6 2024, 14:46:42) [Clang 14.0.6 ] | |
rustworkx version: 0.16.0 | |
Dijkstra on directed path graph with 100000 nodes (run 100 times) took on average 0.6737 ± 0.0607 seconds | |
(base) ➜ minibench uv run experimental_rustworkx.py | |
Python version: 3.12.3 | packaged by Anaconda, Inc. | (main, May 6 2024, 14:46:42) [Clang 14.0.6 ] | |
rustworkx version: 0.17.0 | |
Dijkstra on directed path graph with 100000 nodes (run 100 times) took on average 0.6434 ± 0.0024 seconds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /// script | |
# requires-python = ">=3.9" | |
# dependencies = [ | |
# "rustworkx==0.16.0", | |
# ] | |
# /// | |
import rustworkx as rx | |
import sys | |
import timeit | |
import statistics | |
def benchmark(): | |
N = 100_000 | |
graph = rx.generators.directed_path_graph(N) | |
def run(): | |
# Benchmark Dijkstra from node 0 | |
rx.dijkstra_shortest_path_lengths(graph, 0, edge_cost_fn=lambda _: 1.0) | |
times = timeit.repeat(run, number=100, repeat=10) | |
avg_time = statistics.mean(times) | |
stddev_time = statistics.stdev(times) | |
print(f"Dijkstra on directed path graph with {N} nodes (run 100 times) took on average {avg_time:.4f} ± {stddev_time:.4f} seconds") | |
if __name__ == "__main__": | |
print(f"Python version: {sys.version}") | |
print(f"rustworkx version: {rx.__version__}") | |
benchmark() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment