profile.c File Reference
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include "nvim/func_attr.h"
#include "nvim/globals.h"
#include "nvim/os/os_defs.h"
#include "nvim/os/time.h"
#include "nvim/profile.h"


proftime_T profile_start (void)
proftime_T profile_end (proftime_T tm) FUNC_ATTR_WARN_UNUSED_RESULT
const char * profile_msg (proftime_T tm) FUNC_ATTR_WARN_UNUSED_RESULT
proftime_T profile_setlimit (int64_t msec) FUNC_ATTR_WARN_UNUSED_RESULT
bool profile_passed_limit (proftime_T tm) FUNC_ATTR_WARN_UNUSED_RESULT
proftime_T profile_zero (void)
proftime_T profile_divide (proftime_T tm, int count) FUNC_ATTR_CONST
proftime_T profile_add (proftime_T tm1, proftime_T tm2) FUNC_ATTR_CONST
proftime_T profile_sub (proftime_T tm1, proftime_T tm2) FUNC_ATTR_CONST
proftime_T profile_self (proftime_T self, proftime_T total, proftime_T children) FUNC_ATTR_CONST
proftime_T profile_get_wait (void)
void profile_set_wait (proftime_T wait)
 Sets the current waittime. More...
proftime_T profile_sub_wait (proftime_T tm, proftime_T tma) FUNC_ATTR_PURE
bool profile_equal (proftime_T tm1, proftime_T tm2) FUNC_ATTR_CONST
int64_t profile_signed (proftime_T tm) FUNC_ATTR_CONST
int profile_cmp (proftime_T tm1, proftime_T tm2) FUNC_ATTR_CONST
void time_push (proftime_T *rel, proftime_T *start)
void time_pop (proftime_T tp)
void time_start (const char *message)
void time_msg (const char *mesg, const proftime_T *start)

Function Documentation

◆ profile_add()

proftime_T profile_add ( proftime_T  tm1,
proftime_T  tm2 

Adds time tm2 to tm1.

tm1 + tm2

◆ profile_cmp()

int profile_cmp ( proftime_T  tm1,
proftime_T  tm2 

Compares profiling times.

Times tm1 and tm2 must be less than 150 years apart.

<0: tm2 < tm1 0: tm2 == tm1 >0: tm2 > tm1

◆ profile_divide()

proftime_T profile_divide ( proftime_T  tm,
int  count 

Divides time tm by count.

0 if count <= 0, otherwise tm / count

◆ profile_end()

proftime_T profile_end ( proftime_T  tm)

Computes the time elapsed.

Elapsed time from tm until now.

◆ profile_equal()

bool profile_equal ( proftime_T  tm1,
proftime_T  tm2 

Checks if time tm1 is equal to tm2.

true if tm1 == tm2

◆ profile_get_wait()

proftime_T profile_get_wait ( void  )

Gets the current waittime.

the current waittime

◆ profile_msg()

const char* profile_msg ( proftime_T  tm)

Gets a string representing time tm.

Do not modify or free this string, not multithread-safe.
Static string representing tm in the form "seconds.microseconds".

◆ profile_passed_limit()

bool profile_passed_limit ( proftime_T  tm)

Checks if current time has passed tm.

true if the current time is past tm, false if not or if the timer was not set.

◆ profile_self()

proftime_T profile_self ( proftime_T  self,
proftime_T  total,
proftime_T  children 

Adds the self time from the total time and the children time.

if total <= children, then self, otherwise self + total - children

◆ profile_set_wait()

void profile_set_wait ( proftime_T  wait)

Sets the current waittime.

◆ profile_setlimit()

proftime_T profile_setlimit ( int64_t  msec)

Gets the time msec into the future.

msecmilliseconds, the maximum number of milliseconds is (2^63 / 10^6) - 1 = 9.223372e+12.
if msec > 0, returns the time msec past now. Otherwise returns the zero time.

◆ profile_signed()

int64_t profile_signed ( proftime_T  tm)

Converts time duration tm (profile_sub result) to a signed integer.

signed representation of the given time value

◆ profile_start()

proftime_T profile_start ( void  )

Gets the current time.

the current time

◆ profile_sub()

proftime_T profile_sub ( proftime_T  tm1,
proftime_T  tm2 

Subtracts time tm2 from tm1.

Unsigned overflow (wraparound) occurs if tm2 is greater than tm1. Use profile_signed() to get the signed integer value.

See also
tm1 - tm2

◆ profile_sub_wait()

proftime_T profile_sub_wait ( proftime_T  tm,
proftime_T  tma 

Subtracts the passed waittime since tm.

tma - (waittime - tm)

◆ profile_zero()

proftime_T profile_zero ( void  )

Gets the zero time.

the zero time

◆ time_msg()

void time_msg ( const char *  mesg,
const proftime_T start 

Prints out timing info.

don't forget to call time_start() once before calling this.
mesgthe message to display next to the timing information
startonly for do_source: start time

◆ time_pop()

void time_pop ( proftime_T  tp)

Computes the prev time after doing something that could nest.

Subtracts tp from the static global g_prev_time.

tpthe time to subtract

◆ time_push()

void time_push ( proftime_T rel,
proftime_T start 

Saves the previous time before doing something that could nest.

After calling this function, the static global g_prev_time will contain the current time.

[out]relto the time elapsed so far
[out]startthe current time

◆ time_start()

void time_start ( const char *  message)

Initializes the startuptime code.

Must be called once before calling other startuptime code (such as time_{push,pop,msg,...}).

messagethe message that will be displayed