Revision 891fa5aee02932bddd292ca5659228b281a3894d authored by Bhooshan Uday Varsha Gadre on 02 October 2023, 08:16:23 UTC, committed by GitHub on 02 October 2023, 08:16:23 UTC
* Close the file after writing events. Not adding context manager as the class is used only here. * Fixing stupid typo
1 parent 1b0a5da
correlate_perf.py
from pycbc.filter import correlate
from pycbc.filter.matchedfilter import BatchCorrelator, Correlator
from pycbc.types import zeros, complex64, complex128, Array
from time import time
from numpy.random import uniform
niter = 2000
for N in [2**10, 2**15, 2**18]:
a = zeros(N, dtype=complex64)
a.data += uniform(-1, 1, size=len(a))
b = a * 0.5
c = a * 1.5
xs = []
zs = []
for i in range(50):
xs.append(a*i)
zs.append(c*i)
corr = BatchCorrelator(xs, zs, N)
t1 = time()
for i in range(niter):
corr.execute(b)
t2 = time()
print("Batch Correlate Perf Size:{} Time:{:3.3f}".format(
N, (t2-t1)*1000 / niter))
for dtp in [complex64, complex128]:
for N in [2**10, 2**15, 2**20]:
a = zeros(N, dtype=dtp)
a += Array(uniform(-1, 1, size=N) * (1 + -.5j), dtype=a.dtype)
b = zeros(N, dtype=dtp)
c = zeros(N, dtype=dtp)
correlate(a, b, c)
t1 = time()
for i in range(niter):
correlate(a, b, c)
t2 = time()
print("Correlate Perf Type:{} Size:{} Time:{:3.3f}".format(repr(dtp),
N, (t2-t1)*1000 / niter))
if dtp is complex64:
corr = Correlator(a, b, c)
t1 = time()
for i in range(niter):
corr.correlate()
t2 = time()
print("Correlator Perf Type:{} Size:{} Time:{:3.3f}".format(repr(dtp),
N, (t2-t1)*1000 / niter))
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...