plibsys 0.0.5
ptimeprofiler.h File Reference

Time profiler. More...

#include <pmacros.h>
#include <ptypes.h>

Go to the source code of this file.

Typedefs

typedef struct PTimeProfiler_ PTimeProfiler
 Time profiler opaque data structure.
 

Functions

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

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().

Definition in file ptimeprofiler.h.

Typedef Documentation

◆ PTimeProfiler

typedef struct PTimeProfiler_ PTimeProfiler

Time profiler opaque data structure.

Definition at line 57 of file ptimeprofiler.h.

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.