0
|
1 import math
|
|
2 import os
|
|
3 import pydc
|
5
|
4 import sys
|
|
5 import platform
|
|
6
|
|
7 if sys.platform == "win32":
|
|
8 libm = pydc.load("msvcrt")
|
|
9 elif sys.platform == "darwin":
|
|
10 libm = pydc.load("/usr/lib/libm.dylib")
|
|
11 elif "bsd" in sys.platform:
|
|
12 libm = pydc.load("/usr/lib/libm.so")
|
|
13 elif platform.architecture()[0] == "64bit":
|
|
14 libm = pydc.load("/lib64/libm.so.6")
|
|
15 else:
|
|
16 libm = pydc.load("/lib/libm.so.6")
|
|
17
|
|
18 fpsin = pydc.find(libm,"sin")
|
|
19
|
|
20
|
0
|
21
|
|
22 def f1(n):
|
|
23 for x in xrange(n):
|
|
24 math.sin(x)
|
|
25 # filter( math.sin, range(0,n) )
|
|
26
|
5
|
27 def libmsin(x): pass
|
0
|
28
|
|
29 def f2(n):
|
|
30 for x in xrange(n):
|
|
31 pydc.call(fpsin,"d)d",float(x))
|
5
|
32 # libmsin(i)
|
0
|
33
|
5
|
34 # filter( libmsin , range(0,n) )
|
0
|
35
|
|
36
|
5
|
37 print "start_native"+str(os.times())
|
0
|
38 f1(10000000)
|
5
|
39 print "start_dc"+str(os.times())
|
|
40 f2(10000000)
|
|
41 print "end"+str(os.times())
|
0
|
42
|