-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbenchmark.py
66 lines (55 loc) · 1.97 KB
/
benchmark.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
59
60
61
62
63
64
65
66
from methods import *
import numpy as np
import time
from tqdm import tqdm
from utils import *
import matplotlib.pyplot as plt
from settings import *
def timeVsnl(nls=np.linspace(50,200,50,dtype=int),Nx=200,Ny=200,Nav=100,getp=False):
""" Computes CPU with increasing nl"""
times = np.zeros((3,len(nls)))
for nav in tqdm(range(Nav)):
for i,nl in enumerate(nls):
X = get_HW(np.random.randint(0,256,nl)) + np.random.normal(0,40,size=(Nx,nl))
Y = get_HW(np.random.randint(0,256,nl)) + np.random.normal(0,40,size=(Nx,nl))
#Ttest
start = time.clock()
t,_,_ = Ttest(X,Y,getp=getp)
end = time.clock()
times[0,i] += end-start
#Hotelling
start = time.clock()
t,_,_ = Tsquare(X,Y,getp=getp)
end = time.clock()
times[1,i] += end-start
#Dtest
start = time.clock()
t,_,_ = MD(X,Y,getp=getp)
end = time.clock()
times[2,i] += end-start
times = times/Nav
return times
def timeVsN(Ns=np.linspace(50,500,50,dtype=int),Nav=100,getp=False,nl=200):
""" Computes CPU with increasing N"""
times = np.zeros((3,len(Ns)))
for nav in tqdm(range(Nav)):
for i,N in enumerate(Ns):
X = get_HW(np.random.randint(0,256,nl)) + np.random.normal(0,40,size=(N,nl))
Y = get_HW(np.random.randint(0,256,nl)) + np.random.normal(0,40,size=(N,nl))
#Ttest
start = time.clock()
t,_,_ = Ttest(X,Y,getp=getp)
end = time.clock()
times[0,i] += end-start
#Hotelling
start = time.clock()
t,_,_ = Tsquare(X,Y,getp=getp)
end = time.clock()
times[1,i] += end-start
#Dtest
start = time.clock()
t,_,_ = MD(X,Y,getp=getp)
end = time.clock()
times[2,i] += end-start
times = times/Nav
return times