Commit 3e2a3e1f authored by Morten Knutsen's avatar Morten Knutsen
Browse files

Resolve massive performance hits after API-rewrite

parent 3e996ab9
......@@ -127,12 +127,13 @@ def read_linkloads(G, host, url):
def calc_ratio(G, loads, u, v, discard_inverse=False, no_diff=False, exclude_edges=[]):
sum = 0
totload = loads[(u,v)]
for (u1,v1,d) in [(v2, u2, d2) for (u2, v2, d2) in G.edges(data=True) if u2 == u]:
if (u1,v1) in exclude_edges:
#for (u1,v1,d) in [(v2, u2, d2) for (u2, v2, d2) in G.edges(data=True) if u2 == u]:
for neighbor in G[u]:
if (neighbor,u) in exclude_edges:
#totload -= loads[(u1,v1)] * calc_ratio(G, loads, u,v)
continue
if discard_inverse and (u1,v1) == (v,u): continue
sum += float(loads[(u1,v1)])
if discard_inverse and (neighbor,u) == (v,u): continue
sum += float(loads[(neighbor,u)])
ee = []
#if discard_inverse: ee += [(v,u)]
ndiff = node_diff_in_out(G, loads, u, False, ee)
......@@ -188,13 +189,11 @@ def node_diff_in_out(G, loads, node, inverse=False, exclude_edges=[]):
sum_out = 0
sum_in = 0
for (u1,v1,d) in G.edges(node, data=True):
if (u1,v1) in exclude_edges: continue
sum_out += loads[(u1,v1)]
for (u1,v1,d) in [(v2, u2, d2) for (u2, v2, d2) in G.edges(data=True) if u2 == node]:
if (u1,v1) in exclude_edges: continue
sum_in += loads[(u1,v1)]
for neighbor in G[node]:
if (node,neighbor) not in exclude_edges:
sum_out += loads[(node,neighbor)]
if (neighbor,node) not in exclude_edges:
sum_in += loads[(neighbor,node)]
if inverse:
return sum_in - sum_out
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment