HawkTracer  0.8.0
cpu_usage.h File Reference
#include <hawktracer/base_types.h>
#include <hawktracer/ht_config.h>

Go to the source code of this file.


typedef typedefHT_DECLS_BEGIN struct _HT_CPUUsageContext HT_CPUUsageContext
 A forward declaration for CPU Usage context. More...


HT_API HT_CPUUsageContextht_cpu_usage_context_create (void *process_id)
 Creates a context for a CPU usage feature. More...
HT_API void ht_cpu_usage_context_destroy (HT_CPUUsageContext *context)
 Destroys CPU Usage context. More...
HT_API float ht_cpu_usage_get_percentage (HT_CPUUsageContext *context)
 Gets a CPU usage percentage for a process. More...

Typedef Documentation

◆ HT_CPUUsageContext

typedef typedefHT_DECLS_BEGIN struct _HT_CPUUsageContext HT_CPUUsageContext

A forward declaration for CPU Usage context.

This structure should be defined in the implementation file.

Function Documentation

◆ ht_cpu_usage_context_create()

HT_API HT_CPUUsageContext* ht_cpu_usage_context_create ( void *  process_id)

Creates a context for a CPU usage feature.

This context is used for getting percentage CPU usage, and the structure is platform specific. The context should always be destroyed using ht_cpu_usage_context_destroy().

process_ida platform specific description of process ID, or NULL to get CPU usage of the current process. For linux-based platforms, it should be a pointer to a variable of type integer (int), which holds the process ID.
the CPU Usage context.

◆ ht_cpu_usage_context_destroy()

HT_API void ht_cpu_usage_context_destroy ( HT_CPUUsageContext context)

Destroys CPU Usage context.

contexta pointer to the context.

◆ ht_cpu_usage_get_percentage()

HT_API float ht_cpu_usage_get_percentage ( HT_CPUUsageContext context)

Gets a CPU usage percentage for a process.

The process ID should be specified in ht_cpu_usage_context_create().

contexta CPU Usage context.
a CPU usage percentage of a specified process, or negative value on error.