Skip to content

Instantly share code, notes, and snippets.

@milktrader
Last active January 3, 2016 11:49
Show Gist options
  • Save milktrader/8458812 to your computer and use it in GitHub Desktop.
Save milktrader/8458812 to your computer and use it in GitHub Desktop.
Turbo boosting the moving method with Iterators (h/t Slender Means)
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
@carljv
Copy link

carljv commented Jan 17, 2014

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