Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ctype_speedtest.py
- import ctypes
- import ctypes.util
- import time
- clib = ctypes.util.find_library('c')
- sumrange_ctypes = ctypes.cdll.LoadLibrary(clib)
- sumrange_ctypes.restype = ctypes.c_ulonglong
- def test(t):
- return int(t)+1
- 0
- def res(s):
- print "%s: %s cycles in 2 seconds" % (s, c)
- 0
- for i in 'z'*6:
- c = 1
- start_time = time.time()
- while time.time() - start_time < 2:
- c = test(c) # how to run this in ctypes ???
- res('C-Type')
- c = 1
- start_time = time.time()
- while time.time() - start_time < 2:
- c = test(c)
- res('Python')
- print
- #'''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement