Projet

Général

Profil

Projet agregation v2 » Historique » Version 3

Laurent GUERBY, 03/03/2012 09:33

1 1 Laurent GUERBY
h1. Projet agregation v2
2 1 Laurent GUERBY
3 1 Laurent GUERBY
[[Projet agregation]]
4 1 Laurent GUERBY
5 1 Laurent GUERBY
h2. Divers
6 1 Laurent GUERBY
7 1 Laurent GUERBY
* 1 Mbit/s = 83 frames de 1500 byte/sec = 1 frame de 1500 byte toutes les 12 ms
8 1 Laurent GUERBY
* l'augmentation de latence sur la ligne permet la detection de la saturation des buffer
9 1 Laurent GUERBY
* on peut mesurer les variations de latence en regardant les variations de difference de timestamp destination moins source
10 2 Laurent GUERBY
11 2 Laurent GUERBY
Mesure du temps en python : time.time()
12 2 Laurent GUERBY
http://stackoverflow.com/questions/1938048/high-precision-clock-in-python
13 2 Laurent GUERBY
14 2 Laurent GUERBY
<pre>
15 2 Laurent GUERBY
16 2 Laurent GUERBY
guerby@pc2:~/work/tetaneutral.net/python/pa2$ cat ttime.py 
17 2 Laurent GUERBY
import time
18 2 Laurent GUERBY
19 2 Laurent GUERBY
N=1000
20 2 Laurent GUERBY
l=[]
21 2 Laurent GUERBY
for i in xrange(N):
22 2 Laurent GUERBY
    t1=time.time()
23 2 Laurent GUERBY
    t2=time.time()
24 2 Laurent GUERBY
    dt=t2-t1
25 2 Laurent GUERBY
    l.append(dt)
26 2 Laurent GUERBY
27 2 Laurent GUERBY
l.sort()
28 2 Laurent GUERBY
print l[0],l[-1],l[N/2],l[9*N/10]
29 2 Laurent GUERBY
guerby@pc2:~/work/tetaneutral.net/python/pa2$ python ttime.py 
30 2 Laurent GUERBY
9.53674316406e-07 3.00407409668e-05 1.90734863281e-06 2.14576721191e-06
31 2 Laurent GUERBY
guerby@pc2:~/work/tetaneutral.net/python/pa2$ python ttime.py 
32 2 Laurent GUERBY
9.53674316406e-07 1.19209289551e-05 1.90734863281e-06 2.14576721191e-06
33 2 Laurent GUERBY
guerby@pc2:~/work/tetaneutral.net/python/pa2$ python ttime.py 
34 2 Laurent GUERBY
9.53674316406e-07 0.000508069992065 1.90734863281e-06 2.14576721191e-06
35 2 Laurent GUERBY
</pre>
36 2 Laurent GUERBY
37 2 Laurent GUERBY
=> autour de 2 microsecondes en pratique
38 3 Laurent GUERBY
39 3 Laurent GUERBY
Résolution de select en python
40 3 Laurent GUERBY
41 3 Laurent GUERBY
42 3 Laurent GUERBY
guerby@pc2:~/work/tetaneutral.net/python/pa2$ cat tselect.py 
43 3 Laurent GUERBY
import time
44 3 Laurent GUERBY
import select
45 3 Laurent GUERBY
from socket import *
46 3 Laurent GUERBY
from select import select
47 3 Laurent GUERBY
48 3 Laurent GUERBY
49 3 Laurent GUERBY
50 3 Laurent GUERBY
s1 = socket(AF_INET, SOCK_DGRAM)
51 3 Laurent GUERBY
s2 = socket(AF_INET, SOCK_DGRAM)
52 3 Laurent GUERBY
53 3 Laurent GUERBY
N=1000
54 3 Laurent GUERBY
l=[]
55 3 Laurent GUERBY
for i in xrange(N):
56 3 Laurent GUERBY
    t1=time.time()
57 3 Laurent GUERBY
    r = select([s1,s2],[],[],1.0e-9)
58 3 Laurent GUERBY
    t2=time.time()
59 3 Laurent GUERBY
    dt=t2-t1
60 3 Laurent GUERBY
    l.append(dt)
61 3 Laurent GUERBY
62 3 Laurent GUERBY
l.sort()
63 3 Laurent GUERBY
print l[0],l[-1],l[N/2],l[9*N/10]
64 3 Laurent GUERBY
guerby@pc2:~/work/tetaneutral.net/python/pa2$ python tselect.py 
65 3 Laurent GUERBY
9.77516174316e-06 0.000253915786743 1.09672546387e-05 1.12056732178e-05
66 3 Laurent GUERBY
guerby@pc2:~/work/tetaneutral.net/python/pa2$ python tselect.py 
67 3 Laurent GUERBY
9.77516174316e-06 5.41210174561e-05 1.09672546387e-05 1.12056732178e-05
68 3 Laurent GUERBY
69 3 Laurent GUERBY
=> 12 microsecondes