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

Functions

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

proftime_T profile_add ( proftime_T  tm1,
proftime_T  tm2 
)

Adds time tm2 to tm1.

Returns
tm1 + tm2
int profile_cmp ( proftime_T  tm1,
proftime_T  tm2 
)

Compares profiling times.

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

Returns
<0: tm2 < tm1 0: tm2 == tm1 >0: tm2 > tm1
proftime_T profile_divide ( proftime_T  tm,
int  count 
)

Divides time tm by count.

Returns
0 if count <= 0, otherwise tm / count
proftime_T profile_end ( proftime_T  tm)

Computes the time elapsed.

Returns
Elapsed time from tm until now.
bool profile_equal ( proftime_T  tm1,
proftime_T  tm2 
)

Checks if time tm1 is equal to tm2.

Returns
true if tm1 == tm2
proftime_T profile_get_wait ( void  )

Gets the current waittime.

Returns
the current waittime
const char* profile_msg ( proftime_T  tm)

Gets a string representing time tm.

Warning
Do not modify or free this string, not multithread-safe.
Parameters
tmTime
Returns
Static string representing tm in the form "seconds.microseconds".
bool profile_passed_limit ( proftime_T  tm)

Checks if current time has passed tm.

Returns
true if the current time is past tm, false if not or if the timer was not set.
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.

Returns
if total <= children, then self, otherwise self + total - children
void profile_set_wait ( proftime_T  wait)

Sets the current waittime.

proftime_T profile_setlimit ( int64_t  msec)

Gets the time msec into the future.

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

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

Returns
signed representation of the given time value
proftime_T profile_start ( void  )

Gets the current time.

Returns
the current time
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
profile_signed
Returns
tm1 - tm2
proftime_T profile_sub_wait ( proftime_T  tm,
proftime_T  tma 
)

Subtracts the passed waittime since tm.

Returns
tma - (waittime - tm)
proftime_T profile_zero ( void  )

Gets the zero time.

Returns
the zero time
void time_msg ( const char *  mesg,
const proftime_T start 
)

Prints out timing info.

Warning
don't forget to call time_start() once before calling this.
Parameters
mesgthe message to display next to the timing information
startonly for do_source: start time
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.

Parameters
tpthe time to subtract
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.

Parameters
[out]relto the time elapsed so far
[out]startthe current time
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,...}).

Parameters
messagethe message that will be displayed