function cpu_timing_test ( )

%*****************************************************************************80
%
%% cpu_timing_test measures execution time with CPUTIME.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    21 June 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'cpu_timing_test:\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  MATLAB has a built in command called CPUTIME,\n' );
  fprintf ( 1, '  which measures the CPU time elapsed so far.\n' );
  fprintf ( 1, '  The difference of two readings measures the work done lately.\n' );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'TASK #1:\n' )
  fprintf ( 1, '  Multiply two random dense matices of order N\n' );
  fprintf ( 1, '  using MATLAB''s A*B operation.\n' );
  
  n = 100;
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Using matrix size n = %d\n', n );
  A = rand ( n, n );
  B = rand ( n, n );

  t1 = cputime ( );
  C = A * B;
  t2 = cputime ( );

  f = n * n * n;
  w = f / 1000000;
  s = t2 - t1;
  r = w / s;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  MegaFLOPs = %d\n', w );
  fprintf ( 1, '  Elapsed CPU time  = %f\n', s );
  fprintf ( 1, '  MegaFLOPs/second  = %f\n', r );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'TASK #2:\n' )
  fprintf ( 1, '  Multiply two random dense matices of order N\n' );
  fprintf ( 1, '  using explicit loops.\n' );
  
  A = rand ( n, n );
  B = rand ( n, n );

  t1 = cputime ( );
  for i = 1 : n
    for k = 1 : n
      C(i,k) = 0;
      for j = 1 : n
        C(i,k) = C(i,k) + A(i,j) * B(j,k);
      end
    end
  end
  t2 = cputime ( );

  f = n * n * n;
  w = f / 1000000;
  s = t2 - t1;
  r = w / s;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  MegaFLOPs = %d\n', w );
  fprintf ( 1, '  Elapsed CPU time  = %f\n', s );
  fprintf ( 1, '  MegaFLOPs/second  = %f\n', r );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'cpu_timing_test\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end
