Time

This interface enables easy benchmarking using microseconds as unit. More...

Data Structures

struct  Time_Attrs
 Attributes used to create a Time. More...

Typedefs

typedef struct Time_Object * Time_Handle
 Handle through which to reference a Time Object.

Functions

Time_Handle Time_create (Time_Attrs *attrs)
 Creates a Time Object to use for benchmarking. Must be called before a Time_Handle can be used for subsequent operations.
Int Time_delete (Time_Handle hTime)
 Deletes a Time Object. After this call has been made no following Time API calls can be made on this Time_Handle.
Int Time_reset (Time_Handle hTime)
 Resets the state of the timer. Can be called multiple times and must be called before the Time_delta and Time_total functions are called.
Int Time_delta (Time_Handle hTime, Uint32 *deltaPtr)
 Calculates the delta in microseconds between now and the last time delta was called (or when reset was called if that is more recent) on this Time_Handle.
Int Time_total (Time_Handle hTime, Uint32 *totalPtr)
 Calculates the delta in microseconds between now and the last time reset was called on this timer object.

Variables

const Time_Attrs Time_Attrs_DEFAULT
 Default attributes for a Time.

Detailed Description

This interface enables easy benchmarking using microseconds as unit.

The maximum timespan measurable (delta or total) depends on the number of bits of an unsigned long on your system (X), and is 2^X us. With 32-bit unsigned longs this means 2^32 us which is almost 72 minutes.

Typical usage (without error checking):

   #include <xdc/std.h>
   #include <ti/sdo/dmai/Dmai.h>
   #include <ti/sdo/dmai/Time.h>
   Uint32 time1, time2, timeTot;
   Time_Attrs tAttrs = Time_Attrs_DEFAULT;
   Time_Handle hTime;

   Dmai_init();
   hTime = Time_create(&tAttrs);
   Time_reset(hTime);
   fxn1();
   Time_delta(hTime, &time1);
   fxn2();
   Time_delta(hTime), &time2);
   Time_total(hTime, &timeTot);
   printf("Time: fxn1 %u us, fxn2 %u us and total time %u us\n",
           (Uns) time1, (Uns) time2, (Uns) timeTot);

Typedef Documentation

typedef struct Time_Object* Time_Handle

Handle through which to reference a Time Object.


Function Documentation

Time_Handle Time_create ( Time_Attrs attrs  ) 

Creates a Time Object to use for benchmarking. Must be called before a Time_Handle can be used for subsequent operations.

Parameters:
[in] attrs Time_Attrs to use for creating the Time Object.
Return values:
Handle for use in subsequent operations (see Time_Handle).
NULL for failure.

Int Time_delete ( Time_Handle  hTime  ) 

Deletes a Time Object. After this call has been made no following Time API calls can be made on this Time_Handle.

Parameters:
[in] hTime The Time_Handle of the Time Object to delete.
Return values:
Dmai_EOK for success.
Negative value for failure, see Dmai.h.
Remarks:
Time_create must be called before this function.

Int Time_reset ( Time_Handle  hTime  ) 

Resets the state of the timer. Can be called multiple times and must be called before the Time_delta and Time_total functions are called.

Parameters:
[in] hTime Time_Handle to the Time Object to reset.
Return values:
Dmai_EOK for success.
Negative value for failure, see Dmai.h.
Remarks:
Time_create must be called before this function.

Int Time_delta ( Time_Handle  hTime,
Uint32 *  deltaPtr 
)

Calculates the delta in microseconds between now and the last time delta was called (or when reset was called if that is more recent) on this Time_Handle.

Parameters:
[in] hTime Handle of the timer to calculate a delta on.
[out] deltaPtr Pointer to where the resulting value will be stored if the operation was successful.
Return values:
Dmai_EOK for success.
Negative value for failure, see Dmai.h.
Remarks:
Time_create must be called before this function.

Int Time_total ( Time_Handle  hTime,
Uint32 *  totalPtr 
)

Calculates the delta in microseconds between now and the last time reset was called on this timer object.

Parameters:
[in] hTime Handle of the timer to calculate a delta on.
[out] totalPtr Pointer to where the resulting value will be stored if the operation was successful.
Return values:
Dmai_EOK for success.
Negative value for failure, see Dmai.h.
Remarks:
Time_create must be called before this function.


Variable Documentation

Default attributes for a Time.


Copyright 2011, Texas Instruments Incorporated