-
-
Notifications
You must be signed in to change notification settings - Fork 35
benchmarking infrastructure #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
25233c2
benchmarking-initial commit
Schefflera-Arboricola 7857b4a
added common.py and parameters num_nodes and edge_prob(for betweennes…
Schefflera-Arboricola 9f79e9a
some minor edits
Schefflera-Arboricola 31b504f
added benchmarks for all other algos
Schefflera-Arboricola c000f52
applied black and changed num_nodes and edge_prob
Schefflera-Arboricola 2e9c8ab
updated init.py and common.py
Schefflera-Arboricola 77fedc5
typo fix
Schefflera-Arboricola 26a4974
updateed README, removed timing_func, renamed algo_types to backends
Schefflera-Arboricola 06ef1ae
renamed get_graph to get_cached_gnp_random_graph
Schefflera-Arboricola f8e417d
renamed get_graph to get_cached_gnp_random_graph
Schefflera-Arboricola c5c40f4
Merge branch 'networkx:main' into benchmarking
Schefflera-Arboricola 8b04a87
added bench_shortest_paths.py
Schefflera-Arboricola f805169
added dict()
Schefflera-Arboricola 6f8d0d3
Updated __init__.py
Schefflera-Arboricola e40ac1e
Updated asv.conf.json
Schefflera-Arboricola 9c757d0
Merge branch 'networkx:main' into benchmarking
Schefflera-Arboricola 5aba95e
Updated README.md
Schefflera-Arboricola File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,3 +127,7 @@ dmypy.json | |
|
|
||
| # Pyre type checker | ||
| .pyre/ | ||
|
|
||
| # asv | ||
| results/ | ||
| html/ | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| ## Preview benchmarks locally | ||
|
|
||
| 1. clone this repo | ||
| 2. `cd benchmarks` | ||
| 3. `asv run` will run the benchmarks on last commit | ||
| - or use `asv continuous base_commit_hash test_commit_hash` to run the benchmark to compare two commits | ||
| - or `asv run -b <benchmark_file_name> -k <benchmark_name>` to run a particular benchmark. | ||
| - if you are running benchmarks for the first time, you would be asked to enter your machine information after this command. | ||
| 4. `asv publish` will create a `html` folder with the results | ||
| 5. `asv preview` will host the results locally at http://127.0.0.1:8080/ |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| { | ||
| "version": 1, | ||
|
|
||
| "project": "nx-parallel", | ||
|
|
||
| "project_url": "https://github.com/networkx/nx-parallel", | ||
|
|
||
| "repo": "..", | ||
|
|
||
| "branches": ["main"], | ||
|
|
||
| "build_command": [ | ||
| "python -m pip install build hatchling", | ||
| "python -m build .", | ||
| "PIP_NO_BUILD_ISOLATION=false python -mpip wheel --no-deps --no-index -w {build_cache_dir} {build_dir}" | ||
| ], | ||
|
|
||
| "install_command": ["in-dir={env_dir} python -mpip install {wheel_file}"], | ||
|
|
||
| "dvcs": "git", | ||
|
|
||
| "environment_type": "virtualenv", | ||
|
|
||
| "show_commit_url": "https://github.com/networkx/nx-parallel/commit/", | ||
|
|
||
| "matrix": { | ||
| "networkx":[], | ||
| "nx-parallel": [] | ||
| }, | ||
|
|
||
| "benchmark_dir": "benchmarks", | ||
|
|
||
| "env_dir": "env", | ||
|
|
||
| "results_dir": "results", | ||
|
|
||
| "html_dir": "html", | ||
|
|
||
| "build_cache_size": 8 | ||
| } |
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| from .common import * | ||
|
|
||
| class Betweenness(Benchmark): | ||
| params = [(algo_types), | ||
| (num_nodes), | ||
| (edge_prob) | ||
| ] | ||
dschult marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| param_names = ["algo_type", "num_nodes", "edge_prob"] | ||
|
|
||
| def time_betweenness_centrality(self, algo_type, num_nodes, edge_prob): | ||
| timing_func(get_graph(num_nodes, edge_prob), algo_type, func = nx.betweenness_centrality) | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| from .common import * | ||
|
|
||
| class EfficiencyMeasures(Benchmark): | ||
| params = [(algo_types), (num_nodes), (edge_prob)] | ||
| param_names = ["algo_type", "num_nodes", "edge_prob"] | ||
|
|
||
| def time_local_efficiency(self, algotype, num_nodes, edge_prob): | ||
| timing_func(get_graph(num_nodes, edge_prob), algotype, func = nx.local_efficiency) | ||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| from .common import * | ||
|
|
||
| class Isolate(Benchmark): | ||
| params = [(algo_types), (num_nodes), (edge_prob)] | ||
| param_names = ["algo_type", "num_nodes", "edge_prob"] | ||
|
|
||
| def time_number_of_isolates(self, algo_type, num_nodes, edge_prob): | ||
| timing_func(get_graph(num_nodes, edge_prob), algo_type, func = nx.number_of_isolates) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| from .common import * | ||
|
|
||
| def get_tournament_graph(num, seed = 42): | ||
| return nx.tournament.random_tournament(num, seed = seed) | ||
|
|
||
|
|
||
| class Tournament(Benchmark): | ||
| params = [(algo_types), (num_nodes)] | ||
| param_names = ["algo_type", "num_nodes"] | ||
|
|
||
| def time_is_reachable(self, algo_type, num_nodes): | ||
| G = get_tournament_graph(num_nodes) | ||
| timing_func(G, algo_type, nx.tournament.is_reachable, 1, num_nodes) | ||
Schefflera-Arboricola marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| from .common import * | ||
|
|
||
| class Vitality(Benchmark): | ||
| params = [(algo_types), (num_nodes), (edge_prob)] | ||
| param_names = ["algo_type", "num_nodes", "edge_prob"] | ||
|
|
||
| def time_closeness_vitality(self, algo_type, num_nodes, edge_prob): | ||
| timing_func(get_graph(num_nodes, edge_prob), algo_type, func = nx.closeness_vitality) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| from functools import lru_cache | ||
| from pathlib import Path | ||
| import types | ||
| import random | ||
|
|
||
| import networkx as nx | ||
| import nx_parallel as nxp | ||
|
|
||
Schefflera-Arboricola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| CACHE_ROOT = Path(__file__).resolve().parent.parent / 'env' / 'nxp_benchdata' | ||
|
|
||
| algo_types = ["parallel", "sequential"] | ||
| num_nodes = [10, 50, 100, 300, 500] | ||
Schefflera-Arboricola marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| edge_prob = [1, 0.8, 0.6, 0.4, 0.2] | ||
dschult marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| @lru_cache(typed=True) | ||
| def get_graph(num_nodes, edge_prob, is_weighted = False): | ||
| G = nx.fast_gnp_random_graph(num_nodes, edge_prob, seed=42, directed=False) | ||
| if is_weighted: | ||
| random.seed(42) | ||
| for (u, v) in G.edges(): | ||
| G.edges[u, v]['weight'] = random.random() | ||
| return G | ||
|
|
||
| def timing_func(G, algo_type, func, *args, **kwargs): | ||
| if algo_type == "parallel": | ||
| H = nxp.ParallelGraph(G) | ||
| _ = func(H, *args, **kwargs) | ||
| if type(_)==types.GeneratorType: d = dict(_) | ||
| elif algo_type == "sequential": | ||
| _ = func(G, *args, **kwargs) | ||
| if type(_)==types.GeneratorType: d = dict(_) | ||
| # if you want to use the following, then pls add "using_kwargs" in `algo_types` above in line 12 | ||
| #elif algo_type == "using_kwargs": | ||
| # _ = func(G, *args, **kwargs, backend='parallel') | ||
| # if type(_)==types.GeneratorType: d = dict(_) | ||
| else: | ||
| raise ValueError("Unknown algo_type") | ||
|
|
||
|
|
||
| class Benchmark: | ||
| pass | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.