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
a135f810
Unverified
Commit
a135f810
authored
8 years ago
by
Simon Désaulniers
Browse files
Options
Downloads
Patches
Plain Diff
benchmark: create function for displaying plot
parent
2da48557
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/tools/dht/tests.py
+24
-15
24 additions, 15 deletions
python/tools/dht/tests.py
with
24 additions
and
15 deletions
python/tools/dht/tests.py
+
24
−
15
View file @
a135f810
...
@@ -70,6 +70,21 @@ def display_plot(yvals, xvals=None, yformatter=None, display_time=3, **kwargs):
...
@@ -70,6 +70,21 @@ def display_plot(yvals, xvals=None, yformatter=None, display_time=3, **kwargs):
plt
.
plot
(
yvals
,
**
kwargs
)
plt
.
plot
(
yvals
,
**
kwargs
)
plt
.
pause
(
display_time
)
plt
.
pause
(
display_time
)
def
display_traffic_plot
(
ifname
):
"""
Displays the traffic plot for a given interface name.
@param ifname: Interface name.
@type ifname: string
"""
ydata
=
[]
xdata
=
[]
# warning: infinite loop
interval
=
2
for
rate
in
iftop_traffic_data
(
ifname
,
interval
=
interval
):
ydata
.
append
(
rate
)
xdata
.
append
((
xdata
[
-
1
]
if
len
(
xdata
)
>
0
else
0
)
+
interval
)
display_plot
(
ydata
,
xvals
=
xdata
,
yformatter
=
Kbit_format
,
color
=
'
blue
'
)
def
iftop_traffic_data
(
ifname
,
interval
=
2
,
rate_type
=
'
send_receive
'
):
def
iftop_traffic_data
(
ifname
,
interval
=
2
,
rate_type
=
'
send_receive
'
):
"""
"""
Generator (yields data) function collecting traffic data from iftop
Generator (yields data) function collecting traffic data from iftop
...
@@ -210,10 +225,10 @@ class DhtFeatureTest(FeatureTest):
...
@@ -210,10 +225,10 @@ class DhtFeatureTest(FeatureTest):
def
_dhtPut
(
self
,
producer
,
_hash
,
*
values
):
def
_dhtPut
(
self
,
producer
,
_hash
,
*
values
):
with
FeatureTest
.
lock
:
with
FeatureTest
.
lock
:
for
val
in
values
:
for
val
in
values
:
vstr
=
val
.
__str__
()[:
100
]
vstr
=
val
.
__str__
()[:
100
]
DhtNetwork
.
log
(
'
[PUT]:
'
,
_hash
.
toString
(),
'
->
'
,
vstr
+
(
"
...
"
if
len
(
vstr
)
>
100
else
""
))
DhtNetwork
.
log
(
'
[PUT]:
'
,
_hash
.
toString
(),
'
->
'
,
vstr
+
(
"
...
"
if
len
(
vstr
)
>
100
else
""
))
FeatureTest
.
done
+=
1
FeatureTest
.
done
+=
1
producer
.
put
(
_hash
,
val
,
DhtFeatureTest
.
putDoneCb
)
producer
.
put
(
_hash
,
val
,
DhtFeatureTest
.
putDoneCb
)
while
FeatureTest
.
done
>
0
:
while
FeatureTest
.
done
>
0
:
FeatureTest
.
lock
.
wait
()
FeatureTest
.
lock
.
wait
()
...
@@ -367,9 +382,10 @@ class PersistenceTest(DhtFeatureTest):
...
@@ -367,9 +382,10 @@ class PersistenceTest(DhtFeatureTest):
# initial set of values
# initial set of values
i
=
0
i
=
0
for
h
in
hashes
:
for
h
in
hashes
:
self
.
_dhtPut
(
bootstrap
.
front
(),
h
,
*
[
Value
(
v
)
for
v
in
values
])
# TODO: bloque dans le put??
print
(
"
at:
"
,
i
)
self
.
_dhtPut
(
bootstrap
.
front
(),
h
,
*
[
Value
(
v
)
for
v
in
values
])
i
+=
1
print
(
"
at:
"
,
i
)
i
+=
1
def
normalBehavior
(
do
,
t
,
log
=
None
):
def
normalBehavior
(
do
,
t
,
log
=
None
):
nonlocal
nr_values
nonlocal
nr_values
...
@@ -410,14 +426,7 @@ class PersistenceTest(DhtFeatureTest):
...
@@ -410,14 +426,7 @@ class PersistenceTest(DhtFeatureTest):
self
.
_trigger_dp
(
trigger_nodes
,
h
)
self
.
_trigger_dp
(
trigger_nodes
,
h
)
if
self
.
_traffic_plot
:
if
self
.
_traffic_plot
:
ydata
=
[]
display_traffic_plot
(
'
br
'
+
wb
.
ifname
)
xdata
=
[]
# warning: infinite loop
interval
=
2
for
rate
in
iftop_traffic_data
(
"
br
"
+
wb
.
ifname
,
interval
=
interval
):
ydata
.
append
(
rate
)
xdata
.
append
((
xdata
[
-
1
]
if
len
(
xdata
)
>
0
else
0
)
+
interval
)
display_plot
(
ydata
,
xvals
=
xdata
,
yformatter
=
Kbit_format
,
color
=
'
blue
'
)
else
:
else
:
# blocks in matplotlib thread
# blocks in matplotlib thread
while
True
:
while
True
:
...
...
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