-
Notifications
You must be signed in to change notification settings - Fork 3
/
inclusion_test.py
46 lines (43 loc) · 1.08 KB
/
inclusion_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
#!/usr/bin/env python2.4
import time
count_list = [1,
10,
100,
1000,
10000,
100000,
1000000,
]
for num in count_list:
r = range(num)
start = time.time()
obj = r
if 'b' in obj:
print 'found b'
count1 = time.time() - start
print '%.6f seconds to seach %d item list' % (count1,len(obj))
start = time.time()
obj = set(r)
if 'b' in obj:
print 'found b'
count1 = time.time() - start
print '%.6f seconds to seach %d item set' % (count1,len(obj))
start = time.time()
obj = frozenset(r)
if 'b' in obj:
print 'found b'
count1 = time.time() - start
print '%.6f seconds to seach %d item frozenset' % (count1,len(obj))
start = time.time()
obj = dict.fromkeys(r)
if 'b' in obj:
print 'found b'
count1 = time.time() - start
print '%.6f seconds to seach %d item dict' % (count1,len(obj))
start = time.time()
obj = tuple(r)
if 'b' in obj:
print 'found b'
count1 = time.time() - start
print '%.6f seconds to seach %d item tuple' % (count1,len(obj))
print