MATLAB: A QR complexity question

MATLABo(n^3)qr

It is a common understanding that the complexity of QR is O(n^3). But if I do the following simple tests,
>> tic; for k =1:100; a = randn(100); [q r] = qr(a); end; toc
Elapsed time is 0.082818 seconds.
>> tic; for k =1:100; a = randn(1000); [q r] = qr(a); end; toc
Elapsed time is 5.149743 seconds.
why the elapsed time is only increased by about 63 (instead of 1000) in my system ?

Best Answer

The O(n^3) is number of flops, which is not proportional to tic/toc.
  • You time also RANDN
  • Calling QR has overhead that is significant to aithmetic operations
  • CPU caching is less effective for small size
  • Multithreading/parallel is less effective for small size