Ubuntu 16.04
This Installed
#install llvm(If you put it in, the version is 3.Was 8)
$ sudo apt-get install llvm #Other packages were originally included
$ sudo pip3 install enum34 funcsigs
$ sudo LLVM_CONFIG=/usr/bin/llvm-config-3.8 pip3 install llvmlite
$ sudo LLVM_CONFIG=/usr/bin/llvm-config-3.8 pip3 install numba
I'm not sure if time is good for measuring time, but I just want to get a rough idea, so I don't really care.
import time
import numpy as np
import numba
@numba.jit
def rando(a):
for i in range(N):
for j in range(N):
a[i][j] = np.random.rand()
return a
start = time.time()
N = 100
a = np.zeros((N, N))
for i in range(1000):
a = rando(a)
end = time.time()
print(end - start)
You can compare the times by commenting out the @ numba.jit part. It was 1.46s when not commented out and 26.68s when commented out **, which was more than 20 times faster **. On the other hand, when the number of loops was changed from 1000 to 1, it was 0.025s when not commented out and 0.541s when commented out, which was faster without using numba. It still takes a long time to compile at the very beginning.
The first image is the image when the number of loops is around 0, and the second image is the image of the overall elapsed time. The vertical axis is time (seconds), the horizontal axis is the number of loops, green is without numba, and blue is with numba.
Recommended Posts