Problem with cputime

  • Follow


Hi,

I have a problem with the 'cputime' function calculating
to large times (compared to my wristwatch and to tic/toc) in some 
circumstances. For instance,

   N=9000;
   tt=cputime;
   tic;
   A=zeros(36,36);
   b=zeros(36,1);
   for i=1:N
     T=A*A*b;
   end
   tt=cputime-tt;
   fprintf('tt1=%.2f\n',tt);
   fprintf('tt2=%.2f\n',toc);

produces the following output:

tt1=0.62
tt2=0.16

With the 'tt1' time being wrong (according to my wristwatch).
(The 'tt2'-time produced by tic/toc is, however, correct).
The problem disappears if I replace 'A*A*b' with 'A*b' in the for-loop.


Here is my matlab version:

-------------------------------------------------------------------------------------
MATLAB Version 7.10.0.499 (R2010a)
MATLAB License Number: 110162
Operating System: Linux 2.6.32.10-90.fc12.x86_64 #1 SMP Tue Mar 23 
09:47:08 UTC 2010 x86_64
Java VM Version: Java 1.6.0_12-b04 with Sun Microsystems Inc. Java 
HotSpot(TM) 64-Bit Server VM mixed mode
-------------------------------------------------------------------------------------

Thanks for any suggestions,
Haakon Haegland
0
Reply Haakon 4/13/2010 12:20:51 PM


0 Replies
318 Views

(page loaded in 0.014 seconds)

Similiar Articles:













7/25/2012 4:10:42 PM


Reply: