specific
function: >
profile start /tmp/vimprofile
profile func MyFunc
Here is an example of the output, with line
numbers prepended for the explanation:
1 FUNCTION Test2() ~
2 Called 1 time ~
3 Total time: 0.155251 ~
4 Self time: 0.002006 ~
5 ~
6 count total (s) self (s) ~
7 9 0.000096 for i in range(8) ~
8 8 0.153655 0.000410 call Test3() ~
9 8 0.000070 endfor ~
10 " Ask a question ~
11 1 0.001341 echo input("give me an answer: ") ~
The header (lines 1-4) gives the time for the whole function. The "Total"
time is the time passed while the function was executing. The "Self" time is
the "Total" time reduced by time spent in:
- other user defined functions
- sourced scripts
- executed autocommands
- external (shell) commands
Lines 7-11 show the time spent in each executed line. Lines that are not
executed do not count. Thus a comment line is never counted.
The Count column shows how many times a line was executed. Note that the
"for" command in line 7 is executed one more time as the following lines.
That is because the line is also executed to detect the end of the loop.
The time Vim spends waiting for user input isn't counted at all. Thus how
long you take to respond to the input() prompt is irrelevant.
Profiling should give a good indication of where time is spent, but keep in
mind there are various things that may clobber the results:
- Real elapsed time is measured, if other processes are busy they may cause
delays at unpredictable moments. You may want to run the profiling several
times and use the lowest results.
- If you have several commands in one line you only get one time. Split the
line to see the time for the individual commands.
- The time of the lines added up is mostly less than the time of the whole
function. There is some overhead in between.
- Functions that are deleted before Vim exits will not produce profiling
information. You can check the |v:profiling| variable if needed: >
:if !v:profiling
: delfunc MyFunc
:endif
<
- Profiling may give weird results on multi-processor systems, when sleep
mode kicks in or the processor frequency is reduced to save power.
- The "self" time is wrong when a function is used recursively.
==============================================================================
Context *Context* *context*
The editor state is represented by the Context concept. This includes things
like the current |jumplist|, values of |registers|, and more, described below.
*context-types*
The following Context items are supported:
"jumps" |jumplist|
"regs" |registers|
"bufs" |buffer-list|
"gvars" |global-variable|s
"sfuncs" |script-local| functions
"funcs" global and |script-local| functions
*context-dict*
Context objects are dictionaries with the following key-value pairs:
- "jumps", "regs", "bufs", "gvars":
|readfile()|-style |List| representation of corresponding msgpack
objects (see |msgpackdump()| and |msgpackparse()|).
- "funcs" (includes |script-local| functions as well):
|List| of |:function| definitions.
*context-stack*
An initially-empty internal Context stack is maintained by the ctx-family
functions (see |ctx-functions|).
vim:tw=78:ts=8:noet:ft=help:norl: