0

I have a program that calculate CPU time in original system and CPU time in minimun.It suppose that CPU_minimum < CPU_original but in my case occurs the reverse .Here is the code

    clear


load('C.mat');

load('G.mat');

 % start of simulation time for the original state-space model
tic;   


t1 = cputime;

  A = -C\ G;
  BB=sparse(280,4);  
  BB(4,1) = 1;
  BB(6,2)= 1;
  BB(43,3)=1;
  BB(72,4) = 1;

  %disp(BB);

  B =  C\BB;
  C=B';
  D =zeros(4,4);

  sys1 = ss(A,B,C,D)



  totalCPUTime1 = cputime-t1

    fprintf ( 1, 'Creation of the original state-space model needs %1.3f 
   seconds   the CPU.\n', totalCPUTime1 )

  % end of simulation time for original state-space model

  first = toc


   % start of simulation time for the minimum  state-space model
   tic;


    t2 = cputime;
   syss1 = minreal(sys1)


   totalCPUTime2 = cputime-t2

    fprintf ( 1, 'Creation of the minimum state-space model needs %1.3f 
   seconds   the CPU.\n', totalCPUTime2 )


    % end of simulation time for minimum original state-space model
    second = toc

And I get the following CPU time:

    totalCPUTime1= 3.744
    totalCPUTime2= 9.641

Do you know where is the problem?

  • Why do you expect that? Do you known the time complexity of `minreal`? – m7913d Jun 27 '17 at 12:12
  • Your code does not match your given output, `CPU_original` and `CPU_minimum` are not defined. Also, it is not complete as you do not include the mat files. See [mcve] and [ask]. – m7913d Jun 27 '17 at 12:14
  • @m7913d So do you think this is normal? I suppose tha minimun system has less CPU_time – Sokos Smith Jun 27 '17 at 12:17
  • @ m7913d Yes I wrote this that way ,I print the CPUs and get these numbers..okk i change it – Sokos Smith Jun 27 '17 at 12:19
  • 1
    Working with a minimal system may be more efficient, but constructing it can be quite hard. – m7913d Jun 27 '17 at 12:25
  • This post may be of relevance: https://stackoverflow.com/questions/14636665/matlabs-tic-toc-cs-clock-discrepancy. `cputime` is equivalent to measuring clock time, and if this is the case you are comparing apples with oranges when using `tic/toc` in parallel. – rayryeng Jun 27 '17 at 12:28
  • @ m7913d okk thanks for your opinion – Sokos Smith Jun 27 '17 at 12:31

0 Answers0