Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update wavetest.py #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update wavetest.py #29

wants to merge 1 commit into from

Conversation

mikesha2
Copy link

Replaced bottleneck with logically equivalent code. There's a section in the code which appears to be useless, and is causing significant performance issues with large time series.

In line 169: k_pos is independent of k_neg: therefore we may just replace it with its final value.

Lines 170/171 overwrite k_neg every pass. Therefore, the final value of k_neg only depends on the final value of k_pos.

I was taking a significant performance hit for time series of length > 100,000. It's obvious now from the code why: the for loop (line 168) is linear in the time series length, and unnecessarily allocates/deallocates memory repeatedly, with O(n^2) memory used, since the length of k_neg is the same as the iterator i. The exact value is something like (n / 2) (n /2 + 1) / 2 excess memory operations.

Replaced bottleneck with logically equivalent code
@mabelcalim
Copy link
Owner

Hi @mikesha2 , thanks for pointed this out.
I confess that I write scripts without worrying with the best performance.
Thanks for the insight. Sorry it took me so long to approved it.
Mabel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants