-
Notifications
You must be signed in to change notification settings - Fork 0
/
FourierTTs.py
32 lines (25 loc) · 1.11 KB
/
FourierTTs.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
import numpy as np
import time
from IntrovertFourier import fft as my_fft_function # import your function from IntrovertFourier.py
# Generate a test signal
n = 1024 # signal length
dt = 0.01 # time step
t = np.arange(n) * dt # time array
f = 10.0 # signal frequency
signal = np.sin(2 * np.pi * f * t) # input signal
# Apply standard FFT algorithm (numpy.fft.fft) and measure execution time
start_time = time.time()
result_1 = np.fft.fft(signal)
execution_time_1 = time.time() - start_time
from IntrovertFourier import fft as my_fft_function # import your function from IntrovertFourier.py
# Apply IntrovertFourier algorithm and measure execution time
start_time = time.time()
result_2 = my_fft_function(signal)
execution_time_2 = time.time() - start_time
# Compare the results and execution times
if np.allclose(result_1, result_2):
print("The results are the same")
else:
print("The results are different")
print(f"Execution time of standard FFT algorithm: {execution_time_1:.4f} seconds")
print(f"Execution time of IntrovertFourier algorithm: {execution_time_2:.4f} seconds")