diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 0ac6d762..43a1e652 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -11,19 +11,20 @@ permissions: jobs: benchmark: - name: Run pytest-benchmark benchmarks + name: Upload XGI benchmarks runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: 3.13 - - name: Run benchmarks + - name: Install packages run: | pip install --upgrade pip pip install .[benchmark] - pytest benchmarks/bench.py --benchmark-json benchmarks/output.json - + - name: Run benchmarks + run: | + pytest benchmarks/*.py --benchmark-json benchmarks/output.json - name: Store benchmark results uses: benchmark-action/github-action-benchmark@v1 with: diff --git a/benchmarks/bench.py b/benchmarks/core.py similarity index 74% rename from benchmarks/bench.py rename to benchmarks/core.py index b915764f..ce8de19c 100644 --- a/benchmarks/bench.py +++ b/benchmarks/core.py @@ -6,13 +6,14 @@ import xgi +rounds = 100 def test_construct_from_edgelist(benchmark): def setup(): H = xgi.read_hif("benchmarks/email-enron.json") return (H.edges.members(),), {} - benchmark.pedantic(xgi.Hypergraph, setup=setup, rounds=10) + benchmark.pedantic(xgi.Hypergraph, setup=setup, rounds=rounds) def test_construct_from_edgedict(benchmark): @@ -20,7 +21,7 @@ def setup(): H = xgi.read_hif("benchmarks/email-enron.json") return (H.edges.members(dtype=dict),), {} - benchmark.pedantic(xgi.Hypergraph, setup=setup, rounds=10) + benchmark.pedantic(xgi.Hypergraph, setup=setup, rounds=rounds) def test_construct_from_df(benchmark): @@ -28,7 +29,7 @@ def setup(): H = xgi.read_hif("benchmarks/email-enron.json") return (xgi.to_bipartite_pandas_dataframe(H),), {} - benchmark.pedantic(xgi.Hypergraph, setup=setup, rounds=10) + benchmark.pedantic(xgi.Hypergraph, setup=setup, rounds=rounds) def test_node_memberships(benchmark): @@ -39,7 +40,7 @@ def setup(): def node_memberships(H): [H.nodes.memberships(n) for n in H.nodes] - benchmark.pedantic(node_memberships, setup=setup, rounds=10) + benchmark.pedantic(node_memberships, setup=setup, rounds=rounds) def test_edge_members(benchmark): @@ -50,7 +51,7 @@ def setup(): def edge_members(H): [H.edges.members(eid) for eid in H.edges] - benchmark.pedantic(edge_members, setup=setup, rounds=10) + benchmark.pedantic(edge_members, setup=setup, rounds=rounds) def test_node_attributes(benchmark): @@ -61,7 +62,7 @@ def setup(): def node_attributes(H): [H.nodes[nid] for nid in H.nodes] - benchmark.pedantic(node_attributes, setup=setup, rounds=10) + benchmark.pedantic(node_attributes, setup=setup, rounds=rounds) def test_edge_attributes(benchmark): @@ -72,7 +73,7 @@ def setup(): def edge_attributes(H): [H.edges[eid] for eid in H.edges] - benchmark.pedantic(edge_attributes, setup=setup, rounds=10) + benchmark.pedantic(edge_attributes, setup=setup, rounds=rounds) def test_degree(benchmark): @@ -83,7 +84,7 @@ def setup(): def degree(H): H.degree() - benchmark.pedantic(degree, setup=setup, rounds=10) + benchmark.pedantic(degree, setup=setup, rounds=rounds) def test_nodestats_degree(benchmark): @@ -94,7 +95,7 @@ def setup(): def degree(H): H.nodestats.degree.asnumpy() - benchmark.pedantic(degree, setup=setup, rounds=10) + benchmark.pedantic(degree, setup=setup, rounds=rounds) def test_nodestats_degree(benchmark): @@ -105,7 +106,7 @@ def setup(): def degree(H): H.nodes.degree.asnumpy() - benchmark.pedantic(degree, setup=setup, rounds=10) + benchmark.pedantic(degree, setup=setup, rounds=rounds) def test_edge_size(benchmark): @@ -116,7 +117,7 @@ def setup(): def degree(H): H.edges.size.asnumpy() - benchmark.pedantic(degree, setup=setup, rounds=10) + benchmark.pedantic(degree, setup=setup, rounds=rounds) def test_isolates(benchmark): @@ -127,7 +128,7 @@ def setup(): def isolates(H): H.nodes.isolates() - benchmark.pedantic(isolates, setup=setup, rounds=10) + benchmark.pedantic(isolates, setup=setup, rounds=rounds) def test_singletons(benchmark): @@ -138,7 +139,7 @@ def setup(): def singletons(H): H.edges.singletons() - benchmark.pedantic(singletons, setup=setup, rounds=10) + benchmark.pedantic(singletons, setup=setup, rounds=rounds) def test_copy(benchmark): @@ -149,7 +150,7 @@ def setup(): def copy(H): H.copy() - benchmark.pedantic(copy, setup=setup, rounds=10) + benchmark.pedantic(copy, setup=setup, rounds=rounds) def test_dual(benchmark): @@ -160,4 +161,4 @@ def setup(): def dual(H): H.dual() - benchmark.pedantic(dual, setup=setup, rounds=10) + benchmark.pedantic(dual, setup=setup, rounds=rounds)