Last active
January 3, 2016 11:49
-
-
Save milktrader/8458812 to your computer and use it in GitHub Desktop.
Turbo boosting the moving method with Iterators (h/t Slender Means)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia> using Series, MarketData, FactCheck | |
julia> @time fast = fastmoving(Cl, mean, 60); | |
elapsed time: 0.305857977 seconds (72646744 bytes allocated) | |
julia> @time slow = moving(Cl, mean, 60); | |
elapsed time: 4.925385985 seconds (2079575504 bytes allocated) | |
julia> @fact fast[end].value => roughly(slow[end].value) | |
Success :: :(fast[end].value) => :(roughly(slow[end].value)) | |
julia> 4.925385985/0.305857977 | |
16.103506710240225 |
One last comment (hopefully). You may get a slight-to-moderate speedup from just calling map
on the partitions, instead of collect(imap(f, partition(...)))
. If you're just going to collect the entire IMap
right away, you might as well just use map
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The array version even seems to be faster. (Though for some reason more memory-intensive?)