plibsys
Typedefs | Functions
ptimeprofiler.h File Reference

Time profiler. More...

#include <pmacros.h>
#include <ptypes.h>
Include dependency graph for ptimeprofiler.h:

Go to the source code of this file.

Typedefs

typedef typedefP_BEGIN_DECLS struct PTimeProfiler_ PTimeProfiler
 Time profiler opaque data structure. More...
 

Functions

P_LIB_API PTimeProfilerp_time_profiler_new (void)
 Creates a new PTimeProfiler object. More...
 
P_LIB_API void p_time_profiler_reset (PTimeProfiler *profiler)
 Resets the PTimeProfiler's internal counter to zero. More...
 
P_LIB_API puint64 p_time_profiler_elapsed_usecs (const PTimeProfiler *profiler)
 Calculates elapsed time since the last reset or creation. More...
 
P_LIB_API void p_time_profiler_free (PTimeProfiler *profiler)
 Frees PTimeProfiler object. More...
 

Detailed Description

Time profiler.

Author
Alexander Saprykin

PTimeProfiler acts like a time chronometer: in any moment of time you can make a time slice to see how much time elapsed since the last slice or timer start.

This profiler is useful to gather information about execution time for calls or parts of the code. It can help to leverage bottle-necks in your code.

To start using a profiler create a new one with p_time_profiler_new() call and p_time_profiler_elapsed_usecs() to get elapsed time since the creation. If you need to reset a profiler use p_time_profiler_reset(). Remove a profiler with p_time_profiler_free().

Typedef Documentation

◆ PTimeProfiler

typedef typedefP_BEGIN_DECLS struct PTimeProfiler_ PTimeProfiler

Time profiler opaque data structure.

Function Documentation

◆ p_time_profiler_elapsed_usecs()

P_LIB_API puint64 p_time_profiler_elapsed_usecs ( const PTimeProfiler profiler)

Calculates elapsed time since the last reset or creation.

Parameters
profilerTime profiler to calculate elapsed time for.
Returns
Microseconds elapsed since the last reset or creation.
Since
0.0.1

◆ p_time_profiler_free()

P_LIB_API void p_time_profiler_free ( PTimeProfiler profiler)

Frees PTimeProfiler object.

Parameters
profilerPTimeProfiler to free.
Since
0.0.1

◆ p_time_profiler_new()

P_LIB_API PTimeProfiler* p_time_profiler_new ( void  )

Creates a new PTimeProfiler object.

Returns
Pointer to a newly created PTimeProfiler object.
Since
0.0.1

◆ p_time_profiler_reset()

P_LIB_API void p_time_profiler_reset ( PTimeProfiler profiler)

Resets the PTimeProfiler's internal counter to zero.

Parameters
profilerTime profiler to reset.
Since
0.0.1

After a reset the time profiler begins to count elapsed time from that moment of time.