Tizen Native API

This group discusses the functions that allow you to get the time spent in a part of a code.

To create a counter, use eina_counter_new(). To free it, use eina_counter_free().

To time a part of a code, call eina_counter_start() just before it, and eina_counter_stop() just after it. Each time you start to time a code, a clock is added to a list. You can give the number of that clock with the second argument of eina_counter_stop(). To send all the registered clocks to a stream (like stdout, for a file), use eina_counter_dump().

Compile this code with the following command:

 * gcc -Wall -o test_eina_counter test_eina.c `pkg-config --cflags --libs eina`
 * 

The result should be something like this:

 * \# specimen    experiment time    starting time    ending time
 * 1              9794125            783816           10577941
 * 
Remarks:
The displayed time is in nanoseconds.

Functions

Eina_Countereina_counter_new (const char *name)
 Returns a counter.
void eina_counter_free (Eina_Counter *counter)
 Deletes a counter.
void eina_counter_start (Eina_Counter *counter)
 Starts the time count.
void eina_counter_stop (Eina_Counter *counter, int specimen)
 Stops the time count.
char * eina_counter_dump (Eina_Counter *counter)
 Dumps the result of all the clocks of a counter to a stream.

Typedefs

typedef struct _Eina_Counter Eina_Counter
 The structure type containing the counter type.

Function Documentation

char* eina_counter_dump ( Eina_Counter counter)

Dumps the result of all the clocks of a counter to a stream.

This function returns an malloc'd string containing the dump of all the valid clocks of counter. If counter is NULL, the functions exits immediately. Otherwise, the output is formatted like this:

Since :
2.3.1
 * \# specimen    experiment time    starting time    ending time
 * 1              208                120000           120208
 * 
Remarks:
The unit of time is nanoseconds.
Parameters:
[in]counterThe counter
Returns:
A string with a summary of the test
void eina_counter_free ( Eina_Counter counter)

Deletes a counter.

This function removes the clock of counter from the used clocks (see eina_counter_start()) and frees the memory allocated for counter. If counter is NULL, the function returns immediately.

Since :
2.3.1
Parameters:
[in]counterThe counter to delete
Eina_Counter* eina_counter_new ( const char *  name)

Returns a counter.

This function returns a new counter. It is characterized by name. If name is NULL, the function returns NULL immediately. If memory allocation fails, NULL is returned and the error is set to EINA_ERROR_OUT_OF_MEMORY.

Since :
2.3.1
Remarks:
When the new counter is not needed anymore, use eina_counter_free() to free the allocated memory.
Parameters:
[in]nameThe name of the counter
Returns:
A newly allocated counter
void eina_counter_start ( Eina_Counter counter)

Starts the time count.

This function specifies that the part of the code beginning just after its call is being timed, using counter. If counter is NULL, this function returns immediately.

Since :
2.3.1
Remarks:
This function adds the clock associated to counter in a list. If the memory needed by that clock cannot be allocated, the function returns and the error is set to EINA_ERROR_OUT_OF_MEMORY.
To stop the timing, eina_counter_stop() must be called with the same counter.
Parameters:
[in]counterThe counter
void eina_counter_stop ( Eina_Counter counter,
int  specimen 
)

Stops the time count.

This function stops the timing that has been started with eina_counter_start(). counter must be the same as the one used with eina_counter_start(). specimen is the number of the test. If counter or its associated clock is NULL, or if the time can't be retrieved the function exits.

Since :
2.3.1
Parameters:
[in]counterThe counter
[in]specimenThe number of the test