Skip to content

Commit

Permalink
Merge branch 'master' into add-edge-count-backend-call
Browse files Browse the repository at this point in the history
  • Loading branch information
j6k4m8 committed Apr 17, 2024
2 parents 41657e1 + 4438409 commit 8acbd7d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: codspeed-benchmarks

on:
push:
branches:
- "master"
pull_request:
# `workflow_dispatch` allows CodSpeed to trigger backtest
# performance analysis in order to generate initial data.
workflow_dispatch:

jobs:
benchmarks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov pytest-codspeed
# Install "cmake", "cython" for networkit. Must happen first:
pip install --upgrade cmake cython
pip install -e ".[sql]"
- name: Run benchmarks
uses: CodSpeedHQ/action@v2
with:
# token: ${{ secrets.CODSPEED_TOKEN }}
run: pytest . --codspeed
21 changes: 21 additions & 0 deletions grand/backends/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,24 @@ def test_node_count(self, backend):
G.nx.add_node("bar", foo=True)
assert len(G.nx) == 2


@pytest.mark.benchmark
@pytest.mark.parametrize("backend", backend_test_params)
def test_node_addition_performance(backend):
backend, kwargs = backend
G = Graph(backend=backend(directed=True, **kwargs))
for i in range(1000):
G.nx.add_node(i)
assert len(G.nx) == 1000


@pytest.mark.benchmark
@pytest.mark.parametrize("backend", backend_test_params)
def test_get_density_performance(backend):
backend, kwargs = backend
G = Graph(backend=backend(directed=True, **kwargs))
for i in range(1000):
G.nx.add_node(i)
for i in range(1000 - 1):
G.nx.add_edge(i, i + 1)
assert nx.density(G.nx) <= 0.005

0 comments on commit 8acbd7d

Please sign in to comment.