MATLAB: How to improve performance? cpu vs ram vs operating system

cpuoperating systemram

Hi,
I have recently started using matlab ( any type of programming actually) and I dont know if i need to buy a new laptop. I am keeping all my files on google drive and work from uni on desktop or home on laptop.
The desktop pc has i7 cpu at 3.2 Ghz and 6 GB ram, windows 8.1 enterprise.
Laptop has i5 cpu at 2.3 Ghz and 12 GB ram, windows 7 pro.
When i run the same code it takes 450 seconds on my desktop and 912 seconds on my laptop.
Do you think the difference is normal? Any suggestion?
Thanks
Turker

Best Answer

If you mainly solve small linear algebra systems, the CPU has the main influence on the speed. Many i5 laptop processors have 2 cores and the i7 4 cores. Together with the higher frequency and turbo-boost this could explain the factor of 2.
While you can easily buy hardware for the double speed, improving the software can yield a speedup of factor 100:
Vectorization, parallelization, pre-allocation, efficient data structuring and loop optimization, the application of a suitable solver, preferring code which is treated well by Matlab's JIT acceleration (no eval, no changes of the type of variables), inplace operations and using fast libraries for BLAS or Mex functions.
Related Question