Projet

Général

Profil

Projet agregation v2 » Historique » Version 5

Version 4 (Laurent GUERBY, 03/03/2012 09:34) → Version 5/93 (Laurent GUERBY, 03/03/2012 09:36)

h1. Projet agregation v2

[[Projet agregation]]

h2. Divers

* 1 Mbit/s = 83 frames de 1500 byte/sec = 1 frame de 1500 byte toutes les 12 ms
* l'augmentation de latence sur la ligne permet la detection de la saturation des buffer
* on peut mesurer les variations de latence en regardant les variations de difference de timestamp destination moins source

h3. Resolution de time.time()

* http://stackoverflow.com/questions/1938048/high-precision-clock-in-python

<pre>
guerby@pc2:~/work/tetaneutral.net/python/pa2$ cat ttime.py
import time

N=1000
l=[]
for i in xrange(N):
t1=time.time()
t2=time.time()
dt=t2-t1
l.append(dt)

l.sort()
print l[0],l[-1],l[N/2],l[9*N/10]
guerby@pc2:~/work/tetaneutral.net/python/pa2$ python ttime.py
9.53674316406e-07 3.00407409668e-05 1.90734863281e-06 2.14576721191e-06
guerby@pc2:~/work/tetaneutral.net/python/pa2$ python ttime.py
9.53674316406e-07 1.19209289551e-05 1.90734863281e-06 2.14576721191e-06
guerby@pc2:~/work/tetaneutral.net/python/pa2$ python ttime.py
9.53674316406e-07 0.000508069992065 1.90734863281e-06 2.14576721191e-06
</pre>

=> autour de 2 microsecondes en pratique

h3. Résolution de select en python

<pre>
guerby@pc2:~/work/tetaneutral.net/python/pa2$ cat tselect.py
import time
import select
from socket import *
from select import select

s1 = socket(AF_INET, SOCK_DGRAM)
s2 = socket(AF_INET, SOCK_DGRAM)

N=1000
l=[]
for i in xrange(N):
t1=time.time()
r = select([s1,s2],[],[],1.0e-9)
t2=time.time()
dt=t2-t1
l.append(dt)

l.sort()
print l[0],l[-1],l[N/2],l[9*N/10]
guerby@pc2:~/work/tetaneutral.net/python/pa2$ python tselect.py
9.77516174316e-06 0.000253915786743 1.09672546387e-05 1.12056732178e-05
guerby@pc2:~/work/tetaneutral.net/python/pa2$ python tselect.py
9.77516174316e-06 5.41210174561e-05 1.09672546387e-05 1.12056732178e-05
</pre>

=> 12 microsecondes
=> 18 microsecondes avec 5 socket vs 2 donc compter + 2 micro/socket