timestamp 
Author Message
 timestamp

I'm very new to C programming, can someone explain how to use it
(for exsample:to find start timestamp and end timestamp-difference).


Thu, 20 Sep 2001 04:00:00 GMT  
 timestamp

   I'm very new to C programming, can someone explain how to use it
   (for exsample:to find start timestamp and end timestamp-difference).

From the GNU C library manual:

Basic CPU Time Inquiry
----------------------

   To get the elapsed CPU time used by a process, you can use the
`clock' function.  This facility is declared in the header file
`time.h'.

   In typical usage, you call the `clock' function at the beginning and
end of the interval you want to time, subtract the values, and then
divide by `CLOCKS_PER_SEC' (the number of clock ticks per second), like
this:

     #include <time.h>

     clock_t start, end;
     double elapsed;

     start = clock();
     ... /* Do the work. */
     end = clock();
     elapsed = ((double) (end - start)) / CLOCKS_PER_SEC;

   Different computers and operating systems vary wildly in how they
keep track of processor time.  It's common for the internal processor
clock to have a resolution somewhere between hundredth and millionth of
a second.

   In the GNU system, `clock_t' is equivalent to `long int' and
`CLOCKS_PER_SEC' is an integer value.  But in other systems, both
`clock_t' and the type of the macro `CLOCKS_PER_SEC' can be either
integer or floating-point types.  Casting processor time values to
`double', as in the example above, makes sure that operations such as
arithmetic and printing work properly and consistently no matter what
the underlying representation is.

 - Macro: int CLOCKS_PER_SEC
     The value of this macro is the number of clock ticks per second
     measured by the `clock' function.

 - Macro: int CLK_TCK
     This is an obsolete name for `CLOCKS_PER_SEC'.

 - Data Type: clock_t
     This is the type of the value returned by the `clock' function.
     Values of type `clock_t' are in units of clock ticks.

 - Function: clock_t clock (void)
     This function returns the elapsed processor time.  The base time is
     arbitrary but doesn't change within a single process.  If the
     processor time is not available or cannot be represented, `clock'
     returns the value `(clock_t)(-1)'.
--
(In need of an experienced ANSI C and cross-platform programmer?
 I'm seeking a programming internship for summer of 1999.)
Please: do not email me copies of your posts to comp.lang.c
        do not ask me C questions via email; post them instead



Thu, 20 Sep 2001 04:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. UNIX timestamp

2. Build timestamp

3. a predefined compile-timestamp token?

4. How to maintain TimeStamp consistency across Time Zones?

5. finding file creation timestamp

6. Getting Assembly compilation timestamp

7. Decoding the VMS 64bit timestamp...

8. getting timestamp from time()

9. can C access timestamps?

10. Can C pick up the timestamp of file

11. timestamp

12. Change file -> change timestamp of file

 

 
Powered by phpBB® Forum Software