-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add profiling to test performance of self-rolled graph vs networkx
- Loading branch information
Showing
15 changed files
with
166 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -12,3 +12,6 @@ build/ | |
.idea/ | ||
release.sh | ||
|
||
.mypy_cache/ | ||
|
||
|
This file contains 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 |
---|---|---|
|
@@ -23,4 +23,5 @@ | |
|
||
from .classes import * | ||
from .loaders import * | ||
|
||
from . import rand | ||
from . import inference |
This file contains 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from .dag import DAG | ||
from .pdag import PDAG | ||
from .gaussdag import GaussDAG | ||
from .gaussdag import GaussDAG, GaussIntervention |
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,5 +1 @@ | ||
from .pcalg import pcalg | ||
from .ges import ges | ||
|
||
|
||
|
||
from . import structural |
This file contains 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,2 @@ | ||
from .pcalg import pcalg | ||
from .ges import ges |
This file contains 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,3 @@ | ||
from .graphs import * | ||
|
||
|
This file contains 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
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains 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,52 @@ | ||
import causaldag as cd | ||
import networkx as nx | ||
from profiling.time_dec import timed | ||
|
||
|
||
@timed | ||
def test_create_nx_small(): | ||
for _ in range(10000): | ||
g = nx.DiGraph() | ||
g.add_edge(1, 2) | ||
g.add_edge(2, 3) | ||
g.add_edge(1, 3) | ||
|
||
|
||
@timed | ||
def test_create_dag_small(): | ||
for _ in range(10000): | ||
g = cd.DAG() | ||
g.add_arc(1, 2) | ||
g.add_arc(2, 3) | ||
g.add_arc(1, 3) | ||
|
||
|
||
test_create_nx_small() | ||
test_create_dag_small() | ||
|
||
import numpy as np | ||
np.random.seed(1729) | ||
nnodes_large = 1000 | ||
arcs = cd.rand.directed_erdos(nnodes_large, .5).arcs | ||
print(len(arcs)) | ||
|
||
|
||
@timed | ||
def test_create_nx_large(): | ||
for i in range(10): | ||
print(i) | ||
g = nx.DiGraph() | ||
g.add_nodes_from(range(nnodes_large)) | ||
g.add_edges_from(arcs) | ||
|
||
|
||
@timed | ||
def test_create_dag_large(): | ||
for i in range(10): | ||
print(i) | ||
g = cd.DAG(nodes=range(nnodes_large), arcs=arcs) | ||
|
||
|
||
test_create_nx_large() | ||
test_create_dag_large() | ||
|
This file contains 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,14 @@ | ||
from functools import wraps | ||
import time | ||
|
||
|
||
def timed(func): | ||
"""This decorator prints the execution time for the decorated function.""" | ||
@wraps(func) | ||
def wrapper(*args, **kwargs): | ||
start = time.time() | ||
result = func(*args, **kwargs) | ||
end = time.time() | ||
print("{} ran in {}s".format(func.__name__, round(end - start, 2))) | ||
return result | ||
return wrapper |
This file contains 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
This file contains 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