Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
2f3d720e
Commit
2f3d720e
authored
Feb 03, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the DNS benchmark; fix a warning compiling cares.pyx. [skip ci]
parent
24e7e819
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
2 deletions
+95
-2
_setuputils.py
_setuputils.py
+1
-1
src/gevent/resolver/cares.pyx
src/gevent/resolver/cares.pyx
+1
-1
src/gevent/resolver/libcares.pxd
src/gevent/resolver/libcares.pxd
+0
-0
src/greentest/bench_dns_resolver.py
src/greentest/bench_dns_resolver.py
+93
-0
No files found.
_setuputils.py
View file @
2f3d720e
...
...
@@ -168,7 +168,7 @@ except ImportError:
return
extensions
def
cythonize1
(
ext
):
new_ext
=
cythonize
([
ext
],
include_path
=
[
'src/gevent'
,
'src/gevent/libev'
])[
0
]
new_ext
=
cythonize
([
ext
],
include_path
=
[
'src/gevent'
,
'src/gevent/libev'
,
'src/gevent/resolver'
])[
0
]
for
optional_attr
in
(
'configure'
,
'optional'
):
if
hasattr
(
ext
,
optional_attr
):
setattr
(
new_ext
,
optional_attr
,
...
...
src/gevent/resolver/cares.pyx
View file @
2f3d720e
...
...
@@ -4,7 +4,7 @@
# can't compile ("local variable 'result' referenced before assignment").
# See https://github.com/cython/cython/issues/1786
# cython: auto_pickle=False
cimport
cares
cimport
libcares
as
cares
import
sys
from
cpython.ref
cimport
Py_INCREF
...
...
src/gevent/resolver/cares.pxd
→
src/gevent/resolver/
lib
cares.pxd
View file @
2f3d720e
File moved
src/greentest/bench_dns_resolver.py
0 → 100644
View file @
2f3d720e
from
__future__
import
absolute_import
,
print_function
# Best run with dnsmasq configured as a caching nameserver
# with no timeouts and configured to point there via
# /etc/resolv.conf and GEVENTARES_SERVERS=
import
gevent.monkey
;
gevent
.
monkey
.
patch_all
()
import
gevent
import
sys
import
socket
import
time
from
zope.dottedname.resolve
import
resolve
as
drresolve
blacklist
=
{
22
,
55
,
68
,
69
,
99
,
120
,
130
,
152
,
161
,
165
,
169
,
172
,
199
,
205
,
239
,
235
,
254
,
256
}
RUN_COUNT
=
15
if
hasattr
(
sys
,
'pypy_version_info'
)
else
5
def
quiet
(
f
,
n
):
try
:
f
(
n
)
except
socket
.
gaierror
:
pass
def
resolve_seq
(
res
,
count
=
10
,
begin
=
0
):
for
index
in
range
(
begin
,
count
+
begin
):
if
index
in
blacklist
:
continue
try
:
res
.
gethostbyname
(
'www.x%s.com'
%
index
)
except
socket
.
gaierror
:
pass
def
resolve_par
(
res
,
count
=
10
,
begin
=
0
):
gs
=
[]
for
index
in
range
(
begin
,
count
+
begin
):
if
index
in
blacklist
:
continue
gs
.
append
(
gevent
.
spawn
(
quiet
,
res
.
gethostbyname
,
'www.x%s.com'
%
index
)
)
gevent
.
joinall
(
gs
)
def
run_all
(
name
,
resolve
=
resolve_par
):
count
=
100
res
=
drresolve
(
'gevent.resolver.'
+
name
+
'.Resolver'
)
before
=
time
.
time
()
resolve
(
res
(),
count
=
count
)
after1
=
time
.
time
()
resolve
(
res
(),
count
=
count
,
begin
=
count
)
after2
=
time
.
time
()
resolve
(
res
(),
count
=
count
,
begin
=
count
*
2
)
after3
=
time
.
time
()
return
(
name
,
before
,
after1
,
after2
,
after3
)
def
make_results
():
result_map
=
{}
names
=
'dnspython'
,
'blocking'
,
'ares'
,
'thread'
for
name
in
names
:
print
(
"Testing"
,
name
)
results
=
[]
for
_
in
range
(
RUN_COUNT
):
r
=
run_all
(
name
)
delta
=
r
[
-
1
]
-
r
[
1
]
print
(
"
\
t
%.2f"
%
delta
,
end
=
""
)
sys
.
stdout
.
flush
()
results
.
append
((
delta
,
r
))
results
.
sort
()
best
=
results
[
0
]
print
(
"
\
n
%s: best of %d runs: %.2f; worst: %.2f"
%
(
name
,
RUN_COUNT
,
best
[
0
],
results
[
-
1
][
0
]))
result_map
[
name
]
=
best
[
1
]
return
[
result_map
[
x
]
for
x
in
names
]
results
=
make_results
()
print
(
'| Resolver | One Iteration | Three Iterations | Delta 3 - two | '
)
print
(
'| -------- | ------------: | ----------------:| -------------:|'
)
for
result
in
results
:
name
,
before
,
after1
,
after2
,
after3
=
result
one_it
=
after1
-
before
two_it
=
after2
-
before
three_it
=
after3
-
before
delta2
=
after2
-
after1
delta
=
after3
-
after2
print
(
"| %9s | %13.2f | %16.2f | %13.2f |"
%
(
name
,
one_it
,
three_it
,
delta
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment