MATLAB and Engee speed comparison
In this example we will compare the speed of execution of a simple script implemented in MATLAB and in Engee. For this purpose we need two libraries MATLAB to connect MATLAB computational kernel and TickTock to measure the time consumption when executing scripts in Engee.
Pkg.add(["TickTock"])
Pkg.add("TickTock")
using MATLAB
using TickTock
Now let's compare the speed of assignment and simple calculations by setting a sine wave and a few auxiliary constants.
mat"""
tic
N = 100;
x = (1:N)/N;
y = sin(8*pi*x);
toc
"""
tick()
N = 100;
x = (1:N)/N;
y = sin.(8π.*x);
tock()
As we can see, Julia copes with this task many times faster than MATLAB.
Now let's compare the speed of cycles. For this purpose, let's use all the available acceleration possibilities in Engee - we will use macro.
mat"""
tic
I = repmat(y,100,1);
toc
"""
tick()
I = repeat(y, 100, 1)
tock()
It is obvious that the vector repeat function in MATLAB is much worse than the similar function in Engee.
The next aspect we will compare is the graphical display. Here we should consider that there is no mapping for MATLAB in Engee, but the functions themselves inside the kernel can be performed.
mat"""
tic
pcolor(I);
colormap(bone);
toc
"""
tick()
heatmap(hcat(I...), c=:bone)
tock()
On this example we can see that Engee is much faster with data display as well.
Let's also display the results of the generated data in the form of an image, and run the entire script described above to get a better idea of the final difference in speed.
heatmap(hcat(I...), c=:bone)
mat"""
tic
N = 100;
x = (1:N)/N;
y = sin(8*pi*x);
I = repmat(y,100,1);
pcolor(I);
colormap(bone);
toc
"""
tick()
N = 100;
x = (1:N)/N;
y = sin.(8π.*x);
I = repeat(y, 100, 1)
heatmap(hcat(I...)', c=:bone)
tock()
Conclusion
Based on the above experiment, we can conclude that Julia performs calculations much faster than MATLAB.