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
0c686bd6
Commit
0c686bd6
authored
9 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
python tools: adapt to latest cython API changes
parent
d2be36b6
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
python/tools/benchmark.py
+19
-6
19 additions, 6 deletions
python/tools/benchmark.py
python/tools/dhtnetwork.py
+3
-3
3 additions, 3 deletions
python/tools/dhtnetwork.py
python/tools/scanner.py
+8
-8
8 additions, 8 deletions
python/tools/scanner.py
with
30 additions
and
17 deletions
python/tools/benchmark.py
+
19
−
6
View file @
0c686bd6
...
...
@@ -47,14 +47,20 @@ def getsTimesTest():
plt
.
ion
()
lines
=
plt
.
plot
([])
plt
.
ylabel
(
'
time (s)
'
)
#plt.show()
fig
,
axes
=
plt
.
subplots
(
2
,
1
)
fig
.
tight_layout
()
lax
=
axes
[
0
]
hax
=
axes
[
1
]
lines
=
None
#ax.plot([])
#plt.ylabel('time (s)')
hax
.
set_ylim
(
0
,
2
)
# let the network stabilise
plt
.
pause
(
5
)
plt
.
pause
(
60
)
start
=
time
.
time
()
#
start = time.time()
times
=
[]
done
=
0
...
...
@@ -83,6 +89,12 @@ def getsTimesTest():
lines
=
plt
.
plot
(
times
,
color
=
'
blue
'
)
plt
.
draw
()
def
run_get
():
nonlocal
done
done
+=
1
start
=
time
.
time
()
bootstrap
.
front
().
get
(
InfoHash
.
getRandom
(),
getcb
,
lambda
ok
,
nodes
:
donecb
(
ok
,
nodes
,
start
))
plt
.
pause
(
5
)
plt
.
show
()
...
...
@@ -101,6 +113,7 @@ def getsTimesTest():
while
done
>
0
:
lock
.
wait
()
update_plot
()
update_plot
()
print
(
"
Took
"
,
np
.
sum
(
times
),
"
mean
"
,
np
.
mean
(
times
),
"
std
"
,
np
.
std
(
times
),
"
min
"
,
np
.
min
(
times
),
"
max
"
,
np
.
max
(
times
))
print
(
'
GET calls timings benchmark test : DONE.
'
\
...
...
@@ -143,7 +156,7 @@ if __name__ == '__main__':
output
,
err
=
p
.
communicate
()
print
(
output
.
decode
())
bootstrap
=
DhtNetwork
(
iface
=
'
br
'
+
args
.
ifname
,
first_bootstrap
=
False
if
args
.
bootstrap
else
True
,
bootstrap
=
[(
args
.
bootstrap
,
"
5000
"
)])
bootstrap
=
DhtNetwork
(
iface
=
'
br
'
+
args
.
ifname
,
first_bootstrap
=
False
if
args
.
bootstrap
else
True
,
bootstrap
=
[(
args
.
bootstrap
,
"
5000
"
)]
if
args
.
bootstrap
else
[]
)
bootstrap
.
resize
(
1
)
procs
=
[
None
for
_
in
range
(
clusters
)]
...
...
This diff is collapsed.
Click to expand it.
python/tools/dhtnetwork.py
+
3
−
3
View file @
0c686bd6
...
...
@@ -14,9 +14,9 @@ class DhtNetwork(object):
@staticmethod
def
run_node
(
ip4
,
ip6
,
p
,
bootstrap
=
[],
is_bootstrap
=
False
):
print
(
"
run_node
"
,
ip4
,
ip6
,
p
,
bootstrap
)
id
=
Py
Identity
()
#id.generate("dhtbench"+str(p),
Py
Identity(), 1024)
n
=
Py
DhtRunner
()
id
=
Identity
()
#id.generate("dhtbench"+str(p), Identity(), 1024)
n
=
DhtRunner
()
n
.
run
(
id
,
ipv4
=
ip4
if
ip4
else
""
,
ipv6
=
ip6
if
ip6
else
""
,
port
=
p
,
is_bootstrap
=
is_bootstrap
)
for
b
in
bootstrap
:
n
.
bootstrap
(
b
[
0
],
b
[
1
])
...
...
This diff is collapsed.
Click to expand it.
python/tools/scanner.py
+
8
−
8
View file @
0c686bd6
...
...
@@ -38,7 +38,7 @@ from mpl_toolkits.basemap import Basemap
import
GeoIP
done
=
0
all_nodes
=
Py
NodeSet
()
all_nodes
=
NodeSet
()
plt
.
ion
()
plt
.
figaspect
(
2.
)
...
...
@@ -76,8 +76,8 @@ gi6 = GeoIP.open("GeoLiteCityv6.dat", GeoIP.GEOIP_INDEX_CACHE | GeoIP.GEOIP_CHEC
def
gcb
(
v
):
return
True
r
=
Py
DhtRunner
()
i
=
Py
Identity
()
r
=
DhtRunner
()
i
=
Identity
()
i
.
generate
(
bits
=
1024
)
r
.
run
(
i
,
port
=
4112
)
...
...
@@ -105,13 +105,13 @@ def nextstep(cur_h, cur_depth, ok, nodes, arc=None, lines=[]):
del
arc
for
l
in
lines
:
l
.
set_color
(
'
#444444
'
)
snodes
=
Py
NodeSet
()
snodes
=
NodeSet
()
snodes
.
extend
(
nodes
)
all_nodes
.
extend
(
nodes
)
depth
=
min
(
6
,
Py
InfoHash
.
commonBits
(
snodes
.
first
(),
snodes
.
last
())
+
4
)
depth
=
min
(
6
,
InfoHash
.
commonBits
(
snodes
.
first
(),
snodes
.
last
())
+
4
)
if
cur_depth
<
depth
:
for
b
in
range
(
cur_depth
,
depth
):
new_h
=
Py
InfoHash
(
cur_h
.
toString
());
new_h
=
InfoHash
(
cur_h
.
toString
());
new_h
.
setBit
(
b
,
1
);
step
(
new_h
,
b
+
1
);
done
-=
1
...
...
@@ -138,7 +138,7 @@ def restart(arg):
points
=
[]
print
(
arg
)
start_h
=
Py
InfoHash
()
start_h
=
InfoHash
()
start_h
.
setBit
(
159
,
1
)
step
(
start_h
,
0
)
plt
.
draw
()
...
...
@@ -209,7 +209,7 @@ def update_plot():
if
run
:
# start first step
start_h
=
Py
InfoHash
()
start_h
=
InfoHash
()
start_h
.
setBit
(
159
,
1
)
step
(
start_h
,
0
)
...
...
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