RTS API Documentation  1.10.11
Typedefs | Functions
switch_profile.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct profile_timer switch_profile_timer_t
 

Functions

switch_profile_timer_tswitch_new_profile_timer (void)
 create a new profile timer More...
 
switch_bool_t switch_get_system_idle_time (switch_profile_timer_t *p, double *idle_percentage)
 provides the percentage of idle system time More...
 
void switch_delete_profile_timer (switch_profile_timer_t **p)
 Deletes profile timer. More...
 

Typedef Documentation

◆ switch_profile_timer_t

Definition at line 37 of file switch_profile.h.

Function Documentation

◆ switch_delete_profile_timer()

void switch_delete_profile_timer ( switch_profile_timer_t **  p)

Deletes profile timer.

Definition at line 327 of file switch_profile.c.

Referenced by SWITCH_MODULE_RUNTIME_FUNCTION().

328 {
329  if (!p) return;
330 
331 #ifdef __linux__
332  close((*p)->procfd);
333 #endif
334  free((*p)->percentage_of_idle_time_ring);
335  free(*p);
336  *p = NULL;
337 }

◆ switch_get_system_idle_time()

switch_bool_t switch_get_system_idle_time ( switch_profile_timer_t p,
double *  idle_percentage 
)

provides the percentage of idle system time

Parameters
pprofile timer structure previously created with new_profile_timer
pointerto store the percentage of idle time
Returns
false on error true for success
Note
on error idle_percentage will be set to 100

Definition at line 296 of file switch_profile.c.

References SWITCH_FALSE.

Referenced by SWITCH_MODULE_RUNTIME_FUNCTION().

297 {
298  *idle_percentage = 100.0;
299  return SWITCH_FALSE;
300 }

◆ switch_new_profile_timer()

switch_profile_timer_t* switch_new_profile_timer ( void  )

create a new profile timer

Returns
profile timer structure previously created with new_profile_timer, NULL on error

Definition at line 304 of file switch_profile.c.

References profile_timer::cpu_idle_smoothing_depth, switch_runtime::cpu_idle_smoothing_depth, profile_timer::percentage_of_idle_time_ring, runtime, and switch_assert.

Referenced by SWITCH_MODULE_RUNTIME_FUNCTION().

305 {
306  unsigned int x;
307  switch_profile_timer_t *p = calloc(1, sizeof(switch_profile_timer_t));
308 
309  if (!p) return NULL;
310 
313  } else {
314  p->cpu_idle_smoothing_depth = 30;
315  }
316 
317  p->percentage_of_idle_time_ring = calloc(1, sizeof(double) * p->cpu_idle_smoothing_depth);
319 
320  for ( x = 0; x < p->cpu_idle_smoothing_depth; x++ ) {
321  p->percentage_of_idle_time_ring[x] = 100.0;
322  }
323 
324  return p;
325 }
struct switch_runtime runtime
Definition: switch_core.c:86
unsigned int cpu_idle_smoothing_depth
double * percentage_of_idle_time_ring
uint32_t cpu_idle_smoothing_depth
#define switch_assert(expr)