public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* RE: using times()
@ 1997-09-22  3:14 Sergey Okhapkin
  1997-09-22  4:57 ` Valery Fine
  0 siblings, 1 reply; 8+ messages in thread
From: Sergey Okhapkin @ 1997-09-22  3:14 UTC (permalink / raw)
  To: gnu-win32, 'fine@mail.cern.ch'; +Cc: 'Geoffrey Noer'

Valery Fine wrote:
> On 22 Sep 97 at 8:33, Sergey Okhapkin wrote:
> 
> 
> > times() call works on NT only. The underlying syscall
> > GetProcessTimes() unimplemented on windows 95. The output of your
> > examle looks the following on my box (NT4.0 SP3):
> 
>   Probably like this would be better then just ZERO:
> 

I'm not sure. Probably, it's better to return -1 and to set errno to ENOSYS, rather than return incorrect value.

-- 
Sergey Okhapkin, http://www.lexa.ru/sos
Moscow, Russia
Looking for a job

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: using times()
  1997-09-22  3:14 using times() Sergey Okhapkin
@ 1997-09-22  4:57 ` Valery Fine
  1997-09-22 21:09   ` $Bill Luebkert
  0 siblings, 1 reply; 8+ messages in thread
From: Valery Fine @ 1997-09-22  4:57 UTC (permalink / raw)
  To: Sergey Okhapkin, gnu-win32

On 22 Sep 97 at 14:15, Sergey Okhapkin wrote:


> Valery Fine wrote:
> > On 22 Sep 97 at 8:33, Sergey Okhapkin wrote:
> > 
> > 
> > > times() call works on NT only. The underlying syscall
> > > GetProcessTimes() unimplemented on windows 95. The output of your
> > > examle looks the following on my box (NT4.0 SP3):
> > 
> >   Probably like this would be better then just ZERO:
> > 
> 
> I'm not sure. Probably, it's better to return -1 and to set errno to
> ENOSYS, rather than return incorrect value.

  It would be as correct as the user's OS (namely Win95) provides
  Since calling that API user wants (I guess) to estimate the time 
                                                 ========
  and this incorrect value may help him but  ENOSYS ?

  Anyway it can not be absolutely precise value for any system. There 
is some error anyway. This error will be large for Win95. For this 
case the 

                "REAL exact value" <= "supplied"

 and it will be not far from the real one if the user's system is 
 running a single process.

 Is it wrong ?
                   Valery
Dr. Valeri Faine (Valery Fine)
    ------------ -------------   Phone: +41 22 767 4921
CERN                             FAX  : +41 22 767 7155
CH-1211 Geneva, 23               mailto:fine@mail.cern.ch 
Switzerland                      http://nicewww.cern.ch/~fine
                                 
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: using times()
  1997-09-22  4:57 ` Valery Fine
@ 1997-09-22 21:09   ` $Bill Luebkert
  0 siblings, 0 replies; 8+ messages in thread
From: $Bill Luebkert @ 1997-09-22 21:09 UTC (permalink / raw)
  To: fine; +Cc: Sergey Okhapkin, gnu-win32

Valery Fine wrote:
> 
> On 22 Sep 97 at 14:15, Sergey Okhapkin wrote:
> 
> > Valery Fine wrote:
> > > On 22 Sep 97 at 8:33, Sergey Okhapkin wrote:
> > >
> > >
> > > > times() call works on NT only. The underlying syscall
> > > > GetProcessTimes() unimplemented on windows 95. The output of your
> > > > examle looks the following on my box (NT4.0 SP3):
> > >
> > >   Probably like this would be better then just ZERO:
> > >
> >
> > I'm not sure. Probably, it's better to return -1 and to set errno to
> > ENOSYS, rather than return incorrect value.
> 
>   It would be as correct as the user's OS (namely Win95) provides
>   Since calling that API user wants (I guess) to estimate the time
>                                                  ========
>   and this incorrect value may help him but  ENOSYS ?
> 
>   Anyway it can not be absolutely precise value for any system. There
> is some error anyway. This error will be large for Win95. For this
> case the
> 
>                 "REAL exact value" <= "supplied"
> 
>  and it will be not far from the real one if the user's system is
>  running a single process.
> 
>  Is it wrong ?

I would say yes, you are wrong.  Sergey pointed out that the function
is not implemented on Win95.  Returning any value other than error 
would be a mistake in my opinion.

I agree with Sergey's response and -1 should be returned on Win95 
until it's possible to actually implement the feature.

-- 
  ,-/-  __      _  _         $Bill Luebkert
 (_/   /  )    // //       DBE Collectibles
  / ) /--<  o // //      http://www.wgn.net/~dbe/
-/-' /___/_<_</_</_    Email: dbe@wgn.net
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: using times()
@ 1997-09-22  8:15 Earnie Boyd
  0 siblings, 0 replies; 8+ messages in thread
From: Earnie Boyd @ 1997-09-22  8:15 UTC (permalink / raw)
  To: fine, sos, gnu-win32

>From: "Valery Fine" <fine@mail.cern.ch>
>To: Sergey Okhapkin <sos@prospect.com.ru>, gnu-win32@cygnus.com
>Date: Mon, 22 Sep 1997 13:56:18 +0100
>Subject: RE: using times()
>
>On 22 Sep 97 at 14:15, Sergey Okhapkin wrote:
>
>
>> Valery Fine wrote:
>> > On 22 Sep 97 at 8:33, Sergey Okhapkin wrote:
>> > 
>> > 
>> > > times() call works on NT only. The underlying syscall
>> > > GetProcessTimes() unimplemented on windows 95. The output of your
>> > > examle looks the following on my box (NT4.0 SP3):
>> > 
>> >   Probably like this would be better then just ZERO:
>> > 
>> 
>> I'm not sure. Probably, it's better to return -1 and to set errno to
>> ENOSYS, rather than return incorrect value.
>
>  It would be as correct as the user's OS (namely Win95) provides
>  Since calling that API user wants (I guess) to estimate the time 
>                                                 ========
>  and this incorrect value may help him but  ENOSYS ?
>
>  Anyway it can not be absolutely precise value for any system. There 
>is some error anyway. This error will be large for Win95. For this 
>case the 
>
>                "REAL exact value" <= "supplied"
>
> and it will be not far from the real one if the user's system is 
> running a single process.
>
> Is it wrong ?
>                   Valery
>Dr. Valeri Faine (Valery Fine)
>    ------------ -------------   Phone: +41 22 767 4921
>CERN                             FAX  : +41 22 767 7155
>CH-1211 Geneva, 23               mailto:fine@mail.cern.ch 
>Switzerland                      http://nicewww.cern.ch/~fine
>                                 
>-
>For help on using this list (especially unsubscribing), send a message 
to
>"gnu-win32-request@cygnus.com" with one line of text: "help".
>


I agree with Valery.


-        \\||//
---o0O0--Earnie--0O0o----
-earnie_boyd@hotmail.com-
------ooo0O--O0ooo-------


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: using times()
@ 1997-09-22  8:15 Earnie Boyd
  0 siblings, 0 replies; 8+ messages in thread
From: Earnie Boyd @ 1997-09-22  8:15 UTC (permalink / raw)
  To: fine, sos, gnu-win32

>From: "Valery Fine" <fine@mail.cern.ch>
>To: Sergey Okhapkin <sos@prospect.com.ru>, gnu-win32@cygnus.com
>Date: Mon, 22 Sep 1997 13:56:18 +0100
>Subject: RE: using times()
>
>On 22 Sep 97 at 14:15, Sergey Okhapkin wrote:
>
>
>> Valery Fine wrote:
>> > On 22 Sep 97 at 8:33, Sergey Okhapkin wrote:
>> > 
>> > 
>> > > times() call works on NT only. The underlying syscall
>> > > GetProcessTimes() unimplemented on windows 95. The output of your
>> > > examle looks the following on my box (NT4.0 SP3):
>> > 
>> >   Probably like this would be better then just ZERO:
>> > 
>> 
>> I'm not sure. Probably, it's better to return -1 and to set errno to
>> ENOSYS, rather than return incorrect value.
>
>  It would be as correct as the user's OS (namely Win95) provides
>  Since calling that API user wants (I guess) to estimate the time 
>                                                 ========
>  and this incorrect value may help him but  ENOSYS ?
>
>  Anyway it can not be absolutely precise value for any system. There 
>is some error anyway. This error will be large for Win95. For this 
>case the 
>
>                "REAL exact value" <= "supplied"
>
> and it will be not far from the real one if the user's system is 
> running a single process.
>
> Is it wrong ?
>                   Valery
>Dr. Valeri Faine (Valery Fine)
>    ------------ -------------   Phone: +41 22 767 4921
>CERN                             FAX  : +41 22 767 7155
>CH-1211 Geneva, 23               mailto:fine@mail.cern.ch 
>Switzerland                      http://nicewww.cern.ch/~fine
>                                 
>-
>For help on using this list (especially unsubscribing), send a message 
to
>"gnu-win32-request@cygnus.com" with one line of text: "help".
>


I agree with Valery.


-        \\||//
---o0O0--Earnie--0O0o----
-earnie_boyd@hotmail.com-
------ooo0O--O0ooo-------


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: using times()
  1997-09-21 21:32 Sergey Okhapkin
@ 1997-09-22  0:55 ` Valery Fine
  0 siblings, 0 replies; 8+ messages in thread
From: Valery Fine @ 1997-09-22  0:55 UTC (permalink / raw)
  To: Sergey Okhapkin, gnu-win32

On 22 Sep 97 at 8:33, Sergey Okhapkin wrote:


> times() call works on NT only. The underlying syscall
> GetProcessTimes() unimplemented on windows 95. The output of your
> examle looks the following on my box (NT4.0 SP3):

  Probably like this would be better then just ZERO:

//_______________
Duble_t TStopwatch::GetCPUTime(){

  OSVERSIONINFO OsVersionInfo;
  OsVersionInfo.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
  GetVersionEx(&OsVersionInfo);
  if (OsVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
    DWORD       ret;
    FILETIME    ftCreate,       // when the process was created
                ftExit;         // when the process exited

    union     {FILETIME ftFileTime;
               __int64  ftInt64;
              } ftKernel; // time the process has spent in kernel mode

    union     {FILETIME ftFileTime;
               __int64  ftInt64;
              } ftUser;   // time the process has spent in user mode

    HANDLE hProcess = GetCurrentProcess();
    ret = GetProcessTimes (hProcess, &ftCreate, &ftExit,
                                     &ftKernel.ftFileTime,
                                     &ftUser.ftFileTime);
    if (ret != TRUE){
      ret = GetLastError ();
      ::Error ("GetCPUTime", " Error on GetProcessTimes 0x%lx",
      (int)ret);
    }
      return (Double_t) (ftKernel.ftInt64 + ftUser.ftInt64) * gTicks;
  }
  else
      return GetRealTime();
//_______________
Double_t TStopwatch::GetRealTime(){
  union     {FILETIME ftFileTime;
             __int64  ftInt64;
            } ftRealTime; // time the process has spent in kernel mode
  SYSTEMTIME st;
  GetSystemTime(&st);
  SystemTimeToFileTime(&st,&ftRealTime.ftFileTime);
  return (Double_t)ftRealTime.ftInt64 * gTicks;
}


Dr. Valeri Faine (Valery Fine)
    ------------ -------------   Phone: +41 22 767 4921
CERN                             FAX  : +41 22 767 7155
CH-1211 Geneva, 23               mailto:fine@mail.cern.ch 
Switzerland                      http://nicewww.cern.ch/~fine
                                 
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: using times()
@ 1997-09-21 21:32 Sergey Okhapkin
  1997-09-22  0:55 ` Valery Fine
  0 siblings, 1 reply; 8+ messages in thread
From: Sergey Okhapkin @ 1997-09-21 21:32 UTC (permalink / raw)
  To: gnu-win32, 'John Mamer'

John Mamer wrote:
> Ive encountered a problem in trying to call the times()
> function under gnuwin32.  My understanding of the times function

times() call works on NT only. The underlying syscall GetProcessTimes() 
unimplemented on windows 95. The output of your examle looks the following 
on my box (NT4.0 SP3):

e:\usr\src\tests>times.exe
Before calling times()
        Unsigned:                  Double:
User:     4199328                        4199328.000
System:   0                        0.000
Children: 37810832                        37810832.000
After calling times
        Unsigned:                  Double:
User:     80                        80.000
System:   60                        60.000
Children: 0                        0.000
...returned from times: unsigned: 3489928 double:3489928.000000
Before calling times()
        Unsigned:                  Double:
User:     80                        80.000
System:   60                        60.000
Children: 0                        0.000
After calling times
        Unsigned:                  Double:
User:     90                        90.000
System:   70                        70.000
Children: 0                        0.000
...returned from times: unsigned: 3490198 double:3490198.000000
 Elapsed time calculation read from otime.tms_utime:
 Start: 80.000000    End: 90.000000   Elapsed time: 10.000000

--
Sergey Okhapkin, http://www.lexa.ru/sos
Moscow, Russia
Looking for a job

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* using times()
@ 1997-09-21 11:56 John Mamer
  0 siblings, 0 replies; 8+ messages in thread
From: John Mamer @ 1997-09-21 11:56 UTC (permalink / raw)
  To: gnu-win32

Hi there!

Ive encountered a problem in trying to call the times() 
function under gnuwin32.  My understanding of the times function 
is that it takes as an argument a pointer to a structure of type 
tms, this structure is generally of the form:

struct tms{
     clock_t tms_utime;
     clock_t tms_stime;
     clock_t tms_cutime;
     clock_t tms_cstime;
};
Where clock_t is the appropriate type for a clock tick (unsigned 
long) the member tms_utime is the time in clock ticks
expent by the user process, tms_stime is the
 system time so far for this process, tms_cutime is the user time
spent on child processes, and tms_cstime is the system time for
child processes. The  function times() is supposed to return the
number of clock ticks since the system last restarted.
I executed the following code, which times a simple loop.  In the 
code below, I wanted to create a simple timer function that would 
return a double indicating the number of clock ticks spent on the 
user process.  

#include <stdio.h>
#include <stdlib.h>
#include <math.h>


#include <sys/times.h>

double jtime()
     /*This function is supposed to encapsulate the times() function and=20
return a double containing the user time as reported by times().
*/
{
  struct tms otime;
  unsigned long int irr;
  double rr;
  /*Print out buffers before*/
  printf("Before calling times()\n");
  printf("        Unsigned:                  Double: \n");
  printf("User:     %u                        %.3lf  \n",
                      otime.tms_utime,(double)otime.tms_utime);
  printf("System:   %u                        %.3lf  \n",
                      otime.tms_stime,(double)otime.tms_stime);
  printf("Children: %u                        %.3lf  \n",
                      otime.tms_cutime,(double)otime.tms_cutime);

  /*call time*/

  irr=3Dtimes(&otime);

  /*Print out buffers after*/

  printf("After calling times\n");
  printf("        Unsigned:                  Double: \n");
  printf("User:     %u                        %.3lf  \n",
                      otime.tms_utime,(double)otime.tms_utime);
  printf("System:   %u                        %.3lf  \n",
                      otime.tms_stime,(double)otime.tms_stime);
  printf("Children: %u                        %.3lf  \n",
                      otime.tms_cutime,(double)otime.tms_cutime);

  printf("...returned from times: unsigned: %u double:%lf\n",
   irr,(double)irr);
  return(((double)otime.tms_utime));
}


main ()
{
   int ix,jx,kx;
   double t1, t2;
   t1=3Djtime();
   /* something to time*/
   for (ix=3D1; ix<=3D10000; ix++) {
      kx=3Djx+2-jx*2;
   }
   t2=3Djtime();
   printf(" Elapsed time calculation read from otime.tms_utime:\n");
   printf(" Start: %lf    End: %lf   Elapsed time: %lf\n",t1, t2, t2-t1);
}
     =20

Under gnuwin32 I got the following output:

After calling times
        Unsigned:                  Double:=20
User:     3477706751                        3477706751.000 =20
System:   2031161765                        2031161765.000 =20
Children: 0                        0.000 =20
...returned from times: unsigned: 167754 double:167754.000000

After calling times
        Unsigned:                  Double:=20
User:     4162328443                        4162328443.000 =20
System:   2904355490                        2904355490.000 =20
Children: 0                        0.000 =20
...returned from times: unsigned: 168440 double:168440.000000

 Elapsed time calculation read from otime.tms_utime:
 Start: 3477706751.000    End: 4162328443.000   Elapsed time: 684621692.000

These results are pretty unbelievable, even if you scale clock 
ticks by 1000.

Under Linux on the same machine I got:
After calling times
        Unsigned:                  Double:=20
User:     1                        1.000 =20
System:   1                        1.000 =20
Children: 0                        0.000 =20
...returned from times: unsigned: 9642468 double:9642468.000000

After calling times
        Unsigned:                  Double:=20
User:     47                        47.000 =20
System:   1                        1.000 =20
Children: 0                        0.000 =20
...returned from times: unsigned: 9642514 double:9642514.000000

 Elapsed time calculation read from otime.tms_utime:
 Start: 1.000    End: 47.000   Elapsed time: 46.000


My suspicion is that Ive misinterpreted the structure for the 
buffer, or how to invoke times.

Has anyone else encountered a problem like this?  Or better yet,
figured out how to do this correctly?  Also, what is the correct 
scale factor to go from clock ticks to seconds?  


Thank you
john
----------------------
John Mamer
john.mamer@anderson.ucla.edu



----------------------
John Mamer
john.mamer@anderson.ucla.edu


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~1997-09-22 21:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-09-22  3:14 using times() Sergey Okhapkin
1997-09-22  4:57 ` Valery Fine
1997-09-22 21:09   ` $Bill Luebkert
  -- strict thread matches above, loose matches on Subject: below --
1997-09-22  8:15 Earnie Boyd
1997-09-22  8:15 Earnie Boyd
1997-09-21 21:32 Sergey Okhapkin
1997-09-22  0:55 ` Valery Fine
1997-09-21 11:56 John Mamer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).