{"id":19339353,"url":"https://github.com/juliamatlab/julia-matlab-benchmark","last_synced_at":"2025-04-23T02:30:41.878Z","repository":{"id":53318188,"uuid":"195634818","full_name":"juliamatlab/Julia-Matlab-Benchmark","owner":"juliamatlab","description":"This repository is a place for accurate benchmarks between Julia and MATLAB and comparing the two. ","archived":false,"fork":false,"pushed_at":"2021-03-31T14:14:06.000Z","size":19962,"stargazers_count":18,"open_issues_count":4,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-02T06:35:50.157Z","etag":null,"topics":["benchmark","blas","julia","julia-matlab","julia-mkl","julia-openblas","julia-package","julimatlab","matlab"],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juliamatlab.png","metadata":{"files":{"readme":"README-Everything.md","changelog":"Changelogs/JuliaChangelog.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-07T09:49:16.000Z","updated_at":"2022-04-07T12:56:28.000Z","dependencies_parsed_at":"2022-09-02T03:23:06.209Z","dependency_job_id":null,"html_url":"https://github.com/juliamatlab/Julia-Matlab-Benchmark","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliamatlab%2FJulia-Matlab-Benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliamatlab%2FJulia-Matlab-Benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliamatlab%2FJulia-Matlab-Benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliamatlab%2FJulia-Matlab-Benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliamatlab","download_url":"https://codeload.github.com/juliamatlab/Julia-Matlab-Benchmark/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250357537,"owners_count":21417299,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benchmark","blas","julia","julia-matlab","julia-mkl","julia-openblas","julia-package","julimatlab","matlab"],"created_at":"2024-11-10T03:21:25.262Z","updated_at":"2025-04-23T02:30:41.248Z","avatar_url":"https://github.com/juliamatlab.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Julia-Matlab-Benchmark\n\nThis repository is a place for accurate benchmarks between Julia and MATLAB and comparing the two.\n\nVarious commonly used operations for Matrix operations, Mathematical calculations, Data Processing, Image processing, Signal processing, and different algorithms are tested.\n\n#[Julia vs Matlab](https://github.com/juliamatlab/Julia-Matlab-Benchmark#julia-vs-matlab)\n\n#[Julia openBLAS vs Julia MKL](https://github.com/juliamatlab/Julia-Matlab-Benchmark/blob/master/README-Julia-openBLAS-vs-Julia-MKL.md#julia-openblas-vs-julia-mkl)\n\n#[Julia SIMD vs Julia openBLAS](https://github.com/juliamatlab/Julia-Matlab-Benchmark/blob/master/README-Julia-SIMD-vs-Julia-openBLAS.md#julia-simd-vs-julia-openblas)\n\n#[Everything](https://github.com/juliamatlab/Julia-Matlab-Benchmark/blob/master/README-Everything.md#everything)\n\n## Development and Future\nThis repository will be extended as more functions are added to the [JuliaMatlab](https://github.com/juliamatlab) repository, which is meant to map all the Matlab functions to Julia native functions.\n\n## Other Features\n* Latest Julia language is used (compatible with 1.0.4 and higher).\n* Julia + Intel MKL is also tested. (https://github.com/JuliaComputing/MKL.jl)\n* Different number of BLAS threads are tested (`BLAS.set_num_threads(n)`)\n* For some of the functions, Julia's SIMD is tested instead of built-in functions.\n* Accurate benchmarking tools are used both in Julia and MATLAB to get an reliable result\n\n# Everything\n\n## Results\n\n### Matrix Generation\n\nGeneration of a Square Matrix using the `randn()` function and `rand()`.\n\n * MATLAB Code - `mA = randn(matrixSize, matrixSize)`, `mB = randn(matrixSize, matrixSize)`.\n * Julia Code - `mA = randn(matrixSize, matrixSize)`, `mB = randn(matrixSize, matrixSize)`.\n\n![Matrix Generation][01]\n\n### Matrix Addition\n\nAddition of 2 square matrices where each is multiplied by a scalar.\n\n * MATLAB Code - `mA = (scalarA .* mX) + (scalarB .* mY)`.\n * Julia Code - `mA = (scalarA .* mX) .+ (scalarB .* mY)` (Using the dot for [Loop Fusion][50]).\n\n![Matrix Addition][02]\n\n### Matrix Multiplication\n\nMultiplication of 2 square matrices after a scalar is added to each.\n\n * MATLAB Code - `mA = (scalarA + mX) * (scalarB + mY)`.\n * Julia Code - `mA = (scalarA .+ mX) * (scalarB .+ mY)` (Using the dot for [Loop Fusion][50]).\n\n![Matrix Multiplication][03]\n\n### Matrix Quadratic Form\n\nCalculation of Matrix / Vector Quadratic Form.\n\n * MATLAB Code - `mA = ((mX * vX).' * (mX * vX)) + (vB.' * vX) + sacalrC;`.\n * Julia Code - `\tmA = (transpose(mX * vX) * (mX * vX)) .+ (transpose(vB) * vX) .+ scalarC;` (Using the dot for [Loop Fusion][50]).\n\n![Matrix Quadratic Form][04]\n\n### Matrix Reductions\n\nSet of operations which reduce the matrix dimension (Works along one dimension).\nThe operation is done on 2 different matrices on along different dimensions.\nThe result is summed with broadcasting to generate a new matrix.\n * MATLAB Code - `mA = sum(mX, 1) + min(mY, [], 2);`.\n * Julia Code - `mA = sum(mX, dims=1) .+ minimum(mY, dims=2); ` (Using the dot for [Loop Fusion][50]).\n\n![Matrix Reductions][05]\n\n### Element Wise Operations\nSet of operations which are element wise.\n\n * MATLAB Code - `mD = abs(mA) + sin(mB);`, `mE = exp(-(mA .^ 2));` and `mF = (-mB + sqrt((mB .^ 2) - (4 .* mA .* mC))) ./ (2 .* mA);`.\n * Julia Code - `mD = abs.(mA) .+ sin.(mB);`, `mE = exp.(-(mA .^ 2));` and `mF = (-mB .+ sqrt.((mB .^ 2) .- (4 .* mA .* mC))) ./ (2 .* mA);` (Using the dot for [Loop Fusion][50]).\n\n![Element Wise Operations][06]\n\n### Matrix Exponent\n\nCalculation of Matrix Exponent.\n\n * MATLAB Code - `mA = expm(mX);`.\n * Julia Code - `mA = exp(mX);`.\n\n![Matrix Exponent][07]\n\n### Matrix Square Root\n\nCalculation of Matrix Square Root.\n\n * MATLAB Code - `mA = sqrtm(mY);`.\n * Julia Code - `mA = sqrt(mY);`.\n\n\n![Matrix Square Root][08]\n\n### SVD\n\nCalculation of all 3 SVD Matrices.\n\n * MATLAB Code - `[mU, mS, mV] = svd(mX)`.\n * Julia Code - `F = svd(mX, full = false); # F is SVD object`,`\tmU, mS, mV = F;`.\n\n![SVD][09]\n\n### Eigen Decomposition\n\nCalculation of 2 Eigen Decomposition Matrices.\n\n * MATLAB Code - `[mD, mV] = eig(mX)`.\n * Julia Code - `\tF  = eigen(mX); # F is eigen object`, `mD, mV = F;`.\n\n![Eigen Decomposition][10]\n\n### Cholesky Decomposition\n\nCalculation of Cholseky Decomposition.\n\n * MATLAB Code - `mA = cholesky(mY)`.\n * Julia Code - `mA = cholesky(mY)`.\n\n![Cholseky Decomposition][11]\n\n### Matrix Inversion\n\nCalculation of the Inverse and Pseudo Inverse of a matrix.\n\n * MATLAB Code - `mA = inv(mY)` and `mB = pinv(mX)`.\n * Julia Code - `mA = inv(mY)` and `mB = pinv(mX)`.\n\n![Matrix Inversion][12]\n\n### Linear System Solution\n\nSolving a Vector Linear System and a Matrix Linear System.\n\n * MATLAB Code - `vX = mA \\ vB` and `mX = mA \\ mB`.\n * Julia Code - `vX = mA \\ vB` and `mX = mA \\ mB`.\n\n![Linear System Solution][13]\n\n### Linear Least Squares\n\nSolving a Vector Least Squares and a Matrix Least Squares.\nThis is combines Matrix Transpose, Matrix Multiplication, Matrix Inversion (Positive Definite) and Matrix Vector / Matrix Multiplication.\n\n * MATLAB Code - `vX = (mA.' * mA) \\ (mA.' * vB)` and `mX = (mA.' * mA) \\ (mA.' * mB)`.\n * Julia Code - \t`mXT=transpose(mX);\tvA = ( mXT * mX) \\ ( mXT * vB);\tmA = ( mXT * mX) \\ ( mXT * mB);`.\n\n![Linear Least Squares][14]\n\n### Squared Distance Matrix\n\nCalculation of the Squared Distance Matrix between 2 sets of Vectors.\nNamely, each element in the matrix is the squared distance between 2 vectors.\nThis is calculation is needed for instance in the K-Means algorithm.\nIt is composed of Matrix Reduction operation, Matrix Multiplication and Broadcasting.\n\n * MATLAB Code - `mA = sum(mX .^ 2, 1).' - (2 .* mX.' * mY) + sum(mY .^ 2, 1)`.\n * Julia Code - `mA = transpose( sum(mX .^ 2, dims=1) ) .- (2 .* transpose(mX) * mY) .+ sum(mY .^ 2, dims=1);` (Using the dot for [Loop Fusion][50]).\n\n![Squared Distance Matrix][15]\n\n### K-Means Algorithm\n\nRunning 10 iterations of the K-Means Algorithm.\n\n * MATLAB Code - See `MatlabBench.m` at `KMeans()`.\n * Julia Code - See `JuliaBench.jl` at `KMeans()`.\n\n![K-Means Algorithm][16]\n\n\n## How to Run\nDownload repository. Or add the package in Julia:\n```julia\n] add https://github.com/juliamatlab/Julia-Matlab-Benchmark\n```\n### Run the Benchmark - Julia\n* From console:\n\n  ```julia\n  include(\"JuliaMain.jl\");\n  ```\n\n### Run the Benchmark - MATLAB\n* From MATLAB command line :\n\n  ```\n  MatlabMain\n  ```\n\n### Run The Analysis In MATLAB\n * From MATLAB command line\n\n ```MatlabAnalysisMain```.\n * Images of the performance test will be created and displayed.\n\n### Run The Analysis In Julia\n * From Julia command line\n\n ```include(\"JuliaAnalysisMain.jl\");```.\n * Images of the performance test will be created and displayed.\n\n\n ## To Do:\n * This repository will be extended as more functions are added to the [MatLang](https://github.com/juliamatlab/MatLang) repository, which is meant to map all the Matlab functions to Julia native functions\n\n * Check if Julia code is efficient. using https://github.com/JunoLab/Traceur.jl and https://docs.julialang.org/en/v1/manual/performance-tips/index.html\n\n * Add Python (NumPy): Code has been converted from MATLAB to python using smop. Still needs working https://github.com/aminya/smop\n * Add Octave.\n\n## Discourse Discussion Forum:\ncoming soon\n\n\n\n## System Configuration\n * System Model - Dell Latitude 5590\n https://www.dell.com/en-ca/work/shop/dell-tablets/latitude-5590/spd/latitude-15-5590-laptop\n * CPU - Intel(R) Core(TM) i5-8250U @ 1.6 [GHz] 1800 Mhz, 4 Cores, 8 Logical Processors.\n * Memory - 1x8GB DDR4 2400MHz Non-ECC\n * Windows 10 Professional 64 Bit\n * WORD_SIZE: 64\n\n\n * MATLAB R2018b.\n    * BLAS Version (`version -blas`) - `Intel(R) Math Kernel Library Version 2018.0.1 Product Build 20171007 for Intel(R) 64 architecture applications, CNR branch AVX2`\n    * LAPACK Version (`version -lapack`) - `Intel(R) Math Kernel Library Version 2018.0.1 Product Build 20171007 for Intel(R) 64 architecture applications CNR branch AVX2  Linear Algebra Package Version 3.7.0`\n\nTwo version of Julia was used:\n\n * JuliaMKL: Julia 1.4.0 + MKL.\n     * Julia Version (`versioninfo()`) - `Julia VersionVersion 1.4.0-DEV.233 Commit 32e3c9ea36 (2019-10-02 12:28 UTC)`;\n     * BLAS Version - `LinearAlgebra.BLAS.vendor(): Intel MKL `.   For tutorial to install https://github.com/JuliaComputing/MKL.jl\n     * LAPACK Version - `libopenblas64_`.\n     * LIBM Version - `libopenlibm`.\n     * LLVM Version - `libLLVM-6.0.1 (ORCJIT, skylake)`.\n     * JULIA_NUM_THREADS = 1. This number of threads is different from BLAS threads. BLAS threads is changed in the code by `BLAS.set_num_threads(1)` and `BLAS.set_num_threads(4)`\n\n * Julia: Julia 1.4.0\n     * Julia Version (`versioninfo()`) - `Julia VersionVersion 1.4.0-DEV.233 Commit 32e3c9ea36 (2019-10-02 12:28 UTC)`;\n     * BLAS Version - `LinearAlgebra.BLAS.vendor(): openBlas64 `.\n     * LAPACK Version - `libopenblas64_`.\n     * LIBM Version - `libopenlibm`.\n     * LLVM Version - `libLLVM-6.0.1 (ORCJIT, skylake)`.\n     * JULIA_NUM_THREADS = 1. This number of threads is different from BLAS threads. BLAS threads is changed in the code by `BLAS.set_num_threads(1)` and `BLAS.set_num_threads(4)`\n\n  [01]: https://github.com/juliamatlab/Julia-Matlab-Benchmark/raw/master/Figures/Matlab_Julia-1-BLAS-Thread_Julia-4-BLAS-Threads_Julia-MKL_Julia-SIMD-1-BLAS-Thread_Julia-SIMD-4-BLAS-Threads_Julia-MKL-SIMD/Figure1.png\n  [02]: https://github.com/juliamatlab/Julia-Matlab-Benchmark/raw/master/Figures/Matlab_Julia-1-BLAS-Thread_Julia-4-BLAS-Threads_Julia-MKL_Julia-SIMD-1-BLAS-Thread_Julia-SIMD-4-BLAS-Threads_Julia-MKL-SIMD/Figure2.png\n  [03]: https://github.com/juliamatlab/Julia-Matlab-Benchmark/raw/master/Figures/Matlab_Julia-1-BLAS-Thread_Julia-4-BLAS-Threads_Julia-MKL_Julia-SIMD-1-BLAS-Thread_Julia-SIMD-4-BLAS-Threads_Julia-MKL-SIMD/Figure3.png\n  [04]: https://github.com/juliamatlab/Julia-Matlab-Benchmark/raw/master/Figures/Matlab_Julia-1-BLAS-Thread_Julia-4-BLAS-Threads_Julia-MKL_Julia-SIMD-1-BLAS-Thread_Julia-SIMD-4-BLAS-Threads_Julia-MKL-SIMD/Figure4.png\n  [05]: https://github.com/juliamatlab/Julia-Matlab-Benchmark/raw/master/Figures/Matlab_Julia-1-BLAS-Thread_Julia-4-BLAS-Threads_Julia-MKL_Julia-SIMD-1-BLAS-Thread_Julia-SIMD-4-BLAS-Threads_Julia-MKL-SIMD/Figure5.png\n  [06]: https://github.com/juliamatlab/Julia-Matlab-Benchmark/raw/master/Figures/Matlab_Julia-1-BLAS-Thread_Julia-4-BLAS-Threads_Julia-MKL_Julia-SIMD-1-BLAS-Thread_Julia-SIMD-4-BLAS-Threads_Julia-MKL-SIMD/Figure6.png\n  [07]: https://github.com/juliamatlab/Julia-Matlab-Benchmark/raw/master/Figures/Matlab_Julia-1-BLAS-Thread_Julia-4-BLAS-Threads_Julia-MKL_Julia-SIMD-1-BLAS-Thread_Julia-SIMD-4-BLAS-Threads_Julia-MKL-SIMD/Figure7.png\n  [08]: https://github.com/juliamatlab/Julia-Matlab-Benchmark/raw/master/Figures/Matlab_Julia-1-BLAS-Thread_Julia-4-BLAS-Threads_Julia-MKL_Julia-SIMD-1-BLAS-Thread_Julia-SIMD-4-BLAS-Threads_Julia-MKL-SIMD/Figure8.png\n  [09]: https://github.com/juliamatlab/Julia-Matlab-Benchmark/raw/master/Figures/Matlab_Julia-1-BLAS-Thread_Julia-4-BLAS-Threads_Julia-MKL_Julia-SIMD-1-BLAS-Thread_Julia-SIMD-4-BLAS-Threads_Julia-MKL-SIMD/Figure9.png\n  [10]: https://github.com/juliamatlab/Julia-Matlab-Benchmark/raw/master/Figures/Matlab_Julia-1-BLAS-Thread_Julia-4-BLAS-Threads_Julia-MKL_Julia-SIMD-1-BLAS-Thread_Julia-SIMD-4-BLAS-Threads_Julia-MKL-SIMD/Figure10.png\n  [11]: https://github.com/juliamatlab/Julia-Matlab-Benchmark/raw/master/Figures/Matlab_Julia-1-BLAS-Thread_Julia-4-BLAS-Threads_Julia-MKL_Julia-SIMD-1-BLAS-Thread_Julia-SIMD-4-BLAS-Threads_Julia-MKL-SIMD/Figure11.png\n  [12]: https://github.com/juliamatlab/Julia-Matlab-Benchmark/raw/master/Figures/Matlab_Julia-1-BLAS-Thread_Julia-4-BLAS-Threads_Julia-MKL_Julia-SIMD-1-BLAS-Thread_Julia-SIMD-4-BLAS-Threads_Julia-MKL-SIMD/Figure12.png\n  [13]: https://github.com/juliamatlab/Julia-Matlab-Benchmark/raw/master/Figures/Matlab_Julia-1-BLAS-Thread_Julia-4-BLAS-Threads_Julia-MKL_Julia-SIMD-1-BLAS-Thread_Julia-SIMD-4-BLAS-Threads_Julia-MKL-SIMD/Figure13.png\n  [14]: https://github.com/juliamatlab/Julia-Matlab-Benchmark/raw/master/Figures/Matlab_Julia-1-BLAS-Thread_Julia-4-BLAS-Threads_Julia-MKL_Julia-SIMD-1-BLAS-Thread_Julia-SIMD-4-BLAS-Threads_Julia-MKL-SIMD/Figure14.png\n  [15]: https://github.com/juliamatlab/Julia-Matlab-Benchmark/raw/master/Figures/Matlab_Julia-1-BLAS-Thread_Julia-4-BLAS-Threads_Julia-MKL_Julia-SIMD-1-BLAS-Thread_Julia-SIMD-4-BLAS-Threads_Julia-MKL-SIMD/Figure15.png\n  [16]: https://github.com/juliamatlab/Julia-Matlab-Benchmark/raw/master/Figures/Matlab_Julia-1-BLAS-Thread_Julia-4-BLAS-Threads_Julia-MKL_Julia-SIMD-1-BLAS-Thread_Julia-SIMD-4-BLAS-Threads_Julia-MKL-SIMD/Figure16.png\n  [50]: http://julialang.org/blog/2017/01/moredots\n\nThe idea for this repository is taken from https://github.com/aminya/MatlabJuliaMatrixOperationsBenchmark which was a fork from https://github.com/RoyiAvital/MatlabJuliaMatrixOperationsBenchmark\n\n#### By Amin Yahyaabadi\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliamatlab%2Fjulia-matlab-benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliamatlab%2Fjulia-matlab-benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliamatlab%2Fjulia-matlab-benchmark/lists"}