-
Notifications
You must be signed in to change notification settings - Fork 95
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
speed vs numpy #522
Comments
You can fuse sqrt cos sin in a single pass over the data import nimpy
import times
import arraymancer
var
tic, toc: float
# for math
let np = pyImport("numpy")
tic = epochTime()
for i in 0..<200:
discard np.sqrt(np.cos(np.sin(np.linspace(0, 10, 1000))))
toc = epochTime()
echo "np time: ", toc - tic
tic = epochTime()
for i in 0..<200:
discard sqrt(cos(sin(arraymancer.linspace(0, 10, 1000))))
toc = epochTime()
echo "arraymancer time: ", toc - tic
tic = epochTime()
for i in 0..<200:
var t = arraymancer.linspace(0, 10, 1000)
t.apply_inline():
x.sin().cos().sqrt()
toc = epochTime()
echo "arraymancer fused time: ", toc - tic
Depending on the number of cores you have, using
Note: for benchmarking CPU time might give you the wrong figures with parallel code that involves multiple CPUs. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shell and output:
If it is compiled with release
I get time:
Could I improve the speed further?
The text was updated successfully, but these errors were encountered: