Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
47d9bc30
Commit
47d9bc30
authored
8 years ago
by
kaldoran
Browse files
Options
Downloads
Patches
Plain Diff
[Python] Draw benchmark graph in a better way #104
parent
c8266334
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/tools/dht/tests.py
+16
-5
16 additions, 5 deletions
python/tools/dht/tests.py
with
16 additions
and
5 deletions
python/tools/dht/tests.py
+
16
−
5
View file @
47d9bc30
...
@@ -18,6 +18,8 @@ import math
...
@@ -18,6 +18,8 @@ import math
import
numpy
as
np
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
import
networkx
as
nx
import
networkx
as
nx
from
networkx.drawing.nx_agraph
import
graphviz_layout
from
opendht
import
*
from
opendht
import
*
from
dht.network
import
DhtNetwork
,
DhtNetworkSubProcess
from
dht.network
import
DhtNetwork
,
DhtNetworkSubProcess
...
@@ -246,16 +248,23 @@ class PhtTest(FeatureTest):
...
@@ -246,16 +248,23 @@ class PhtTest(FeatureTest):
if
len
(
prefixes
)
==
0
:
if
len
(
prefixes
)
==
0
:
return
return
edges
=
s
e
t
([])
edges
=
li
st
([])
for
prefix
in
prefixes
:
for
prefix
in
prefixes
:
for
i
in
range
(
-
1
,
len
(
prefix
)
-
1
):
for
i
in
range
(
-
1
,
len
(
prefix
)
-
1
):
u
=
prefix
[:
i
+
1
]
u
=
prefix
[:
i
+
1
]
edges
.
add
(
(
""
if
i
==
-
1
else
u
,
u
+
"
0
"
)
)
x
=
(
"
.
"
if
i
==
-
1
else
u
,
u
+
"
0
"
)
edges
.
add
(
(
""
if
i
==
-
1
else
u
,
u
+
"
1
"
)
)
y
=
(
"
.
"
if
i
==
-
1
else
u
,
u
+
"
1
"
)
if
x
not
in
edges
:
edges
.
append
(
x
)
if
y
not
in
edges
:
edges
.
append
(
y
)
# TODO: use a binary tree position layout...
# TODO: use a binary tree position layout...
G
=
nx
.
Graph
(
list
(
edges
))
# UPDATE : In a better way [change lib]
nx
.
draw
(
G
,
with_labels
=
True
,
node_color
=
'
white
'
)
G
=
nx
.
Graph
(
sorted
(
edges
,
key
=
lambda
x
:
len
(
x
[
0
])))
plt
.
title
(
"
PHT: Tree
"
)
pos
=
graphviz_layout
(
G
,
prog
=
'
dot
'
)
nx
.
draw
(
G
,
pos
,
with_labels
=
True
,
node_color
=
'
white
'
)
plt
.
show
()
plt
.
show
()
def
run
(
self
):
def
run
(
self
):
...
@@ -303,6 +312,8 @@ class PhtTest(FeatureTest):
...
@@ -303,6 +312,8 @@ class PhtTest(FeatureTest):
DhtNetwork
.
log
(
'
This insert step took :
'
,
time_taken
,
'
second
'
)
DhtNetwork
.
log
(
'
This insert step took :
'
,
time_taken
,
'
second
'
)
FeatureTest
.
lock
.
wait
()
FeatureTest
.
lock
.
wait
()
time
.
sleep
(
1
)
# Recover entries now that the trie is complete.
# Recover entries now that the trie is complete.
for
key
in
keys
:
for
key
in
keys
:
PhtTest
.
key
=
key
PhtTest
.
key
=
key
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment