Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
nwlandry committed Nov 24, 2024
1 parent a9c77e4 commit 60bb679
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
31 changes: 16 additions & 15 deletions benchmarks/bench.py → benchmarks/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,30 @@

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):
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):
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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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)

0 comments on commit 60bb679

Please sign in to comment.