This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] libfortran/29121 -- Add real(10) and real(16) cpu_time routines


On Fri, Sep 29, 2006 at 10:52:59PM +0200, FX Coudert wrote:
> >2006-09-29  Steven G. Kargl  <kargl@gcc.gnu.org>
> >
> >	* intrinsics/cpu_time.c:  Add cpu_time_10 and cpu_time_16 routines.
> 
> OK. As a note: our testsuite doesn't include testcases for cpu_time.
> 

I don't know a portable way to test cpu_time.  The naive

  program a
  real t0, t1
  call cpu_time(t0)
  call sleep(5)
  call cpu_time(t1)
  print *, t1 - t0
  end program a

simply puts the process to sleep for 5 seconds, but cpu_time
does not accumulate.  We could possibly to something like

program a

  integer i
  real t0, t1, t3, t4, x0, x1, x2

  x0 = 1. / 3.
  x1 = 0.
  x2 = 0.

  call cpu_time(t0)
  do i = 1, 10000
     x1 = x1 + x0
  end do
  call cpu_time(t1)

  x = 1. / 3.
  call cpu_time(t3)
  do i = 1, 20000
     x2 = x2 + x0
  end do
  call cpu_time(t4)

  print *, (t4 - t3) / (t1 - t0)

end program a

In an ideal world the printed value would be 2, but a test
shows values from 1.94 to 1.97.  So, getting a good test
may be difficult.

-- 
Steve


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]