mirror of
https://github.com/emikulic/darkhttpd.git
synced 2023-08-10 21:13:08 +03:00
open_sockets: finer grained timing.
This commit is contained in:
parent
744bac5cb8
commit
e5ce7390c3
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# Opens sockets until they run out.
|
# Opens sockets until they run out.
|
||||||
import sys, socket
|
import sys, socket
|
||||||
|
from time import time
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
request = b'GET /darkhttpd.c HTTP/1.0\r\n'
|
request = b'GET /darkhttpd.c HTTP/1.0\r\n'
|
||||||
@ -9,12 +10,14 @@ def main():
|
|||||||
first = True
|
first = True
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
s = socket.socket()
|
t0 = time(); s = socket.socket()
|
||||||
s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
t1 = time(); s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||||
s.connect(("", 8080))
|
t2 = time(); s.connect(("", 8080))
|
||||||
s.send(request)
|
t3 = time(); s.send(request)
|
||||||
socks.append(s)
|
t4 = time(); socks.append(s)
|
||||||
print(len(socks), 'sockets open')
|
t5 = time()
|
||||||
|
print('%d sockets open, %f sock, %f setsockopt, %f connect, %f send, %f append' % (
|
||||||
|
len(socks), t1-t0, t2-t1, t3-t2, t4-t3, t5-t4))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if first:
|
if first:
|
||||||
print(e)
|
print(e)
|
||||||
|
Loading…
Reference in New Issue
Block a user