Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I recently got a trial version of both Mathematica 9 and MATLAB 13a for Windows. I was stunned by the performance difference in the Windows and the Mac version. It was a simple test in matrix multiplication. Here's the code:

a = RandomReal[{0,1},{1000,2000}];
b = RandomReal[{0,1},{2000,3000}];
Timing[a.b;]

On Windows, running on VMWare Fusion, the above code takes 0.17 second to complete, more or less same as MATLAB. But on the Mac, it takes 1.8 seconds, or 10 times longer to complete the calculation. Something is terribly wrong here. What can be the explanation for this discrepancy? (I have 12GB free RAM on my 2012 Mac Mini so we can rule out memory shortage).

Edit: here some benchmarking information. Windows is running in Bootcamp in the benchmark, not from VMWare Fusion:

                                Mac        Windows
                                -------    -------
Data Fitting                    0.666      0.468
Digits of Pi                    0.711      0.733
Discrete Fourier Transform      1.082      0.874
Eigenvalues of a Matrix         0.737      0.608
Elementary Function             1.072      0.780
Gamma Function                  0.532      0.655
Large Integer Multiplication    0.518      0.608
Matrix Arithmetic               1.         1.108
Matrix Multiplication           0.841      0.562
Matrix Transpose                0.889      0.842
Numerical Integration           1.083      0.764
Polynomial Expansion            0.118      0.094
Random Number Sort              1.459      1.061
Singular Value Decomposition    0.751      0.671
Solving a Linear System         0.767      0.655
------------------------------------------------
Total Time                     12.226     10.483
Benchmark Result                1.132      1.320

Mathematica on Mac seems to be a good 20% slower than on Windows.

share|improve this question
    
To begin with the function name is RandomReal not RandomReals. Did you copy this code exactly? –  Mr.Wizard Aug 4 '13 at 19:31
3  
I'm not on Mac so I can't test this, but I believe that on Windows Dot on packed reals is implemented as a fast Intel® Math Kernel Library call. I am guessing that on the Mac such a call isn't being used for some reason. Perhaps a driver or library is missing; perhaps the developers never bothered to implement it. –  Mr.Wizard Aug 4 '13 at 19:42
1  
@Nasser It is, I've confirmed it. –  Pickett Aug 4 '13 at 20:45
3  
Why not run Needs["Benchmarking`"];Benchmark[] for a full comparison? –  cormullion Aug 4 '13 at 20:52
1  
You may want to use SeedRandom to make sure you are working on the same matrices. On your a.b example I could observe variations of up to 20% on just 10 trials. –  A.G. Dec 16 '13 at 7:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.