VersionBay found Julia’s micro-benchmarks very interesting as it compares the same algorithm across multiple languages. VersionBay decided to take a deeper view at the MATLAB code (perf.m) to answer the following questions:

• How does the same code run on different releases?
• What is the difference between a built-in function and Julia’s implementation of the quick sort algorithm?

### Same Code on Different releases

These box plots show the execution time of Julia’s implementation of quick sort across different releases.

Julia’s implementation became 15x faster from R2015a to R2015b.

This is indeed stated in the release notes of MATLAB:

“The new MATLAB execution engine includes performance improvements to function calls, object-oriented operations, and many other MATLAB operations.

The new execution engine uses just-in-time compilation of all MATLAB code which makes the performance more uniform and predictable. The new engine offers improved quality and provides a platform for future performance optimizations and language enhancements.”

MATLAB R2015b release notes

### Using built-in MATLAB function

VersionBay replaced Julia’s implementation of the quick sort algorithm (shown below) with the built-in function: sort.

```function b = qsort(a)
b = qsort_kernel(a, 1, length(a));
end

function a = qsort_kernel(a, lo, hi)
i = lo;
j = hi;
while i < hi
pivot = a(floor((lo+hi)/2));
while i <= j
while a(i) < pivot, i = i + 1; end
while a(j) > pivot, j = j - 1; end
if i <= j
t = a(i);
a(i) = a(j);
a(j) = t;
i = i + 1;
j = j - 1;
end
end
if lo < j; a=qsort_kernel(a, lo, j); end
lo = i;
j = hi;
end```

becomes

`b = sort(a);`

Comparing performances is often difficult as the same algorithm executed twice can often give slightly different results. To overcome this, the Julia benchmarks run the same algorithm multiple times and use the quickest for the benchmarks. VersionBay shows the box plots of the multiple runs of both algorithms on the same machine. The box plot whiskers indicate the min and max execution times, and the box itself shows the 1st and 3rd quartiles, with the median represented in the middle by a black horizontal line. The chart below shows the Julia implementation on the left, and the built-in sort function on the right, for every version of MATLAB.

The built-in function sort is 7.8x faster than Julia’s implementation in R2018b.

For a more detailed analysis of the built-in sort function in MATLAB R2018b becoming faster see this post.