-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
executable file
·55 lines (44 loc) · 929 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import HRTime
from math import *
from sincos import *
import rtsched
import numpy
from numpy import *
N=100000
realtime = False;
try:
rtpars = rtsched.thread_policy_get(0, rtsched.THREAD_TIME_CONSTRAINT_POLICY )
print "THREAD_TIME_CONSTRAINT_POLICY: ", rtpars
def rt():
if realtime:
rtsched.thread_policy_set( 0, rtsched.THREAD_TIME_CONSTRAINT_POLICY, 5e3, 2.5e3, 3e3 )
except:
def rt():
pass
rt()
HRTime.tic()
for i in range(N):
s=numpy.sin(i)
c=numpy.cos(i)
print HRTime.toc()
rt()
HRTime.tic()
for i in range(N):
(s,c)=sincos(i)
print HRTime.toc()
angles= array( [0,45,90,135,180,225,270,315,360] ) * 2 * pi / 360
print sincos( array( [0,45,90,135,180,225,270,315,360] ), 360 )
print sincos( angles )
rt()
HRTime.tic()
for i in range(N):
s=numpy.sin(angles)
c=numpy.cos(angles)
print HRTime.toc()
print (s,c)
rt()
HRTime.tic()
for i in range(N):
(s,c)=sincos(angles)
print HRTime.toc()
print (s,c)