Skip to content

Commit

Permalink
Tweak benchmarks (#631)
Browse files Browse the repository at this point in the history
* remove unnecessary files

* add benchmarks

* add rounds

* add benchmarks
  • Loading branch information
nwlandry authored Nov 24, 2024
1 parent 60bb679 commit 5bace1a
Show file tree
Hide file tree
Showing 8 changed files with 3,662,034 additions and 173,938 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,4 @@ test.*

# benchmarking files
.benchmarks
benchmarks/output.json
output.json
20 changes: 20 additions & 0 deletions benchmarks/algorithms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import xgi

rounds = 10
fname = "benchmarks/email-eu.json"


def test_connected(benchmark):
def setup():
H = xgi.read_hif(fname)
return (H,), {}

benchmark.pedantic(xgi.is_connected, setup=setup, rounds=rounds)


def test_clustering_coefficient(benchmark):
def setup():
H = xgi.read_hif(fname)
return (H,), {}

benchmark.pedantic(xgi.clustering_coefficient, setup=setup, rounds=rounds)
16 changes: 0 additions & 16 deletions benchmarks/asv.conf.json

This file was deleted.

40 changes: 18 additions & 22 deletions benchmarks/core.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,36 @@
import random

import numpy as np
import pandas as pd
import pytest

import xgi

rounds = 100
rounds = 10
fname = "benchmarks/email-eu.json"


def test_construct_from_edgelist(benchmark):
def setup():
H = xgi.read_hif("benchmarks/email-enron.json")
H = xgi.read_hif(fname)
return (H.edges.members(),), {}

benchmark.pedantic(xgi.Hypergraph, setup=setup, rounds=rounds)


def test_construct_from_edgedict(benchmark):
def setup():
H = xgi.read_hif("benchmarks/email-enron.json")
H = xgi.read_hif(fname)
return (H.edges.members(dtype=dict),), {}

benchmark.pedantic(xgi.Hypergraph, setup=setup, rounds=rounds)


def test_construct_from_df(benchmark):
def setup():
H = xgi.read_hif("benchmarks/email-enron.json")
H = xgi.read_hif(fname)
return (xgi.to_bipartite_pandas_dataframe(H),), {}

benchmark.pedantic(xgi.Hypergraph, setup=setup, rounds=rounds)


def test_node_memberships(benchmark):
def setup():
H = xgi.read_hif("benchmarks/email-enron.json")
H = xgi.read_hif(fname)
return (H,), {}

def node_memberships(H):
Expand All @@ -45,7 +41,7 @@ def node_memberships(H):

def test_edge_members(benchmark):
def setup():
H = xgi.read_hif("benchmarks/email-enron.json")
H = xgi.read_hif(fname)
return (H,), {}

def edge_members(H):
Expand All @@ -56,7 +52,7 @@ def edge_members(H):

def test_node_attributes(benchmark):
def setup():
H = xgi.read_hif("benchmarks/email-enron.json")
H = xgi.read_hif(fname)
return (H,), {}

def node_attributes(H):
Expand All @@ -67,7 +63,7 @@ def node_attributes(H):

def test_edge_attributes(benchmark):
def setup():
H = xgi.read_hif("benchmarks/email-enron.json")
H = xgi.read_hif(fname)
return (H,), {}

def edge_attributes(H):
Expand All @@ -78,7 +74,7 @@ def edge_attributes(H):

def test_degree(benchmark):
def setup():
H = xgi.read_hif("benchmarks/email-enron.json")
H = xgi.read_hif(fname)
return (H,), {}

def degree(H):
Expand All @@ -89,7 +85,7 @@ def degree(H):

def test_nodestats_degree(benchmark):
def setup():
H = xgi.read_hif("benchmarks/email-enron.json")
H = xgi.read_hif(fname)
return (H,), {}

def degree(H):
Expand All @@ -100,7 +96,7 @@ def degree(H):

def test_nodestats_degree(benchmark):
def setup():
H = xgi.read_hif("benchmarks/email-enron.json")
H = xgi.read_hif(fname)
return (H,), {}

def degree(H):
Expand All @@ -111,7 +107,7 @@ def degree(H):

def test_edge_size(benchmark):
def setup():
H = xgi.read_hif("benchmarks/email-enron.json")
H = xgi.read_hif(fname)
return (H,), {}

def degree(H):
Expand All @@ -122,7 +118,7 @@ def degree(H):

def test_isolates(benchmark):
def setup():
H = xgi.read_hif("benchmarks/email-enron.json")
H = xgi.read_hif(fname)
return (H,), {}

def isolates(H):
Expand All @@ -133,7 +129,7 @@ def isolates(H):

def test_singletons(benchmark):
def setup():
H = xgi.read_hif("benchmarks/email-enron.json")
H = xgi.read_hif(fname)
return (H,), {}

def singletons(H):
Expand All @@ -144,7 +140,7 @@ def singletons(H):

def test_copy(benchmark):
def setup():
H = xgi.read_hif("benchmarks/email-enron.json")
H = xgi.read_hif(fname)
return (H,), {}

def copy(H):
Expand All @@ -155,7 +151,7 @@ def copy(H):

def test_dual(benchmark):
def setup():
H = xgi.read_hif("benchmarks/email-enron.json")
H = xgi.read_hif(fname)
return (H,), {}

def dual(H):
Expand Down
Loading

0 comments on commit 5bace1a

Please sign in to comment.