-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntime_testing.py
58 lines (47 loc) · 1.08 KB
/
runtime_testing.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
55
56
57
58
import time
from qango6x6 import Quango6x6
from bitops import bitops
import numpy as np
import util
import random
import sys
b = bitops()
q = Quango6x6()
pos = [
int("0b110010001001010001100110001010110100",2),
int("0b001101010010101100010001110100001011",2)
]
trueset = set()
falseset = set()
booldict = {}
numvals = 100000
for a in range(numvals):
if random.random()>0.5:
trueset.add(a)
booldict[a]=True
else:
falseset.add(a)
booldict[a]=False
checker = np.random.randint(0,int(numvals*1.5),100)
start = time.perf_counter()
tflist = []
for check in checker:
if check in trueset:
tflist.append(True)
elif check in falseset:
tflist.append(False)
else:
tflist.append(None)
end = time.perf_counter()
print(end-start)
print(sys.getsizeof(trueset) + sys.getsizeof(falseset))
start = time.perf_counter()
tflist = []
for check in checker:
if check in booldict:
tflist.append(booldict[check])
else:
tflist.append(None)
end = time.perf_counter()
print(end-start)
print(sys.getsizeof(booldict))