MATLAB and Engee speed comparison
In this example, we will compare the execution speed of a simple script implemented in MATLAB and in Engee. To do this, we will need two libraries MATLAB to connect the MATLAB computing core and TickTock to measure the time required 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 specifying a sine wave and several 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 the cycles. To do this, we will use all available acceleration features in Engee – we use a macro.
mat"""
tic
I = repmat(y,100,1);
toc
"""
tick()
I = repeat(y, 100, 1)
tock()
Obviously, the vector repeat function in MATLAB performs significantly worse than a similar function in Engee.
The next aspect that we will compare is the graphical representation. It should be noted here that there is no mapping for MATLAB in Engee, but the functions themselves can be performed inside the kernel.
mat"""
tic
pcolor(I);
colormap(bone);
toc
"""
tick()
heatmap(hcat(I...), c=:bone)
tock()
In this example, we can see that Engee handles data display much faster.
Also, let's display the results of the generated data as an image, and also run the entire script described above in order to get a clearer picture of the final speed difference.
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 experiment described above, we can conclude that Julia performs calculations much faster than MATLAB.