# Benchmark MATLAB & Julia for Matrix Operations

**URL:** https://discourse.julialang.org/t/benchmark-matlab-julia-for-matrix-operations/2000
**Category:** Performance
**Created:** [February 9, 2017, 12:50pm UTC](https://discourse.julialang.org/t/benchmark-matlab-julia-for-matrix-operations/2000 "2017-02-09T12:50:37Z")
**Posts on this page:** 1
**Showing post:** 115

<div class="post-metadata">

### Author: ![RoyiAvital](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/royiavital/32/571_2.png) [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)
#### Post date: [October 13, 2019, 8:25pm UTC](https://discourse.julialang.org/t/benchmark-matlab-julia-for-matrix-operations/2000/115 "2019-10-13T20:25:31Z")

</div>

> [@antoine-levitt](#):
>
> So the differences are mostly explained by multithreading by default in matlab, bad benchmarking methodology (use `@btime`, or at least repeat do the computation twice and report the second run) and suboptimal implementation in some benchmarks: eg in

Have you seen the code?  
It runs 7 times and the measurement is the median.

It really not cool to be determined without checking.

Regarding the code, Please review the code and point me to any place you think I should add it and I will.  
Just out of curiousity, I’d understand that for existing array it will be important to barodcast / fuse teh assignment with `.=`. But I’d think that for a new generated array it won’t. Not that is the reason they are missing. I was just not aware enough of that. Not very experienced with Julia.

> [@Amin\_Yahyaabadi](#):
>
> The way @RoyiAvital measures the performance (using tic/toc and @elapse) is not reliable. Refer to my benchmarks for a more accurate result.
> 
> ![image](https://global.discourse-cdn.com/julialang/original/3X/d/d/ddee7ffdd3ab0419adc89d07b8b961f3c5befd9f.png)

I think you’re wrong.  
First those results don’t make sense. No way 1 Thread of OpenBLAS can match Intel MKL on 4 threads. I think both @ChrisRackauckas and I pointed at this when you first published those.  
I also think your computer, which is a laptop, might be thermally limited and have single memory channel which means it is memory bounded easily. My CPU is Quad Channel memory hence threading has more potential to improve results.

Second, I do `@elapsed` 7 times and take the median. If Julia use the correct timers in the CPU when `@elapsed` is used it should be a good measure technique. Probably this is what `@btime` is doing under the hood.

---

_[View the full topic](https://discourse.julialang.org/t/benchmark-matlab-julia-for-matrix-operations/2000)._
