Closed axieax closed 2 years ago
Hi @axieax, there was no way to extract the plugin's results.
I just added functionality in PR #16 to make this possible.
There's a new option, --save
, that takes a global variable name that will be used to save the results. The StartupTimeSaved
User autocommand is triggered when this happens.
If you call :StartupTime
with --save target
, then the g:target
variable will have the results when they're ready.
The --hidden
option can be used to suppress the plugin's output, so it can be used only for its side-effects that produce the results.
Here's an example that configures a command to run when the results are ready, then calls --StartupTime
with --save
and --hidden
. The total startup time is echo
'd when it's ready.
:autocmd User StartupTimeSaved echo g:saved_startuptime.startup.mean
:StartupTime --save saved_startuptime --hidden
The plugin runs underlying commands asynchronously, which is why the API relies on an autocmd
to know when the result is ready.
Thanks for the idea!
Thanks so much for this! Not sure if this is a side effect but I've noticed that calling :StartupTime
now results in different readings each time (without restarting Neovim). Not sure if this is expected behaviour because I don't remember it happening before.
That's expected behavior (before and after the update), since profiling is re-conducted each time :StartupTime
is called. For a more reliable estimate, the --tries
option can be used to specify how many times to profile (e.g., --tries 5
will launch Neovim five times), with the average reported. But this comes at the cost of taking longer to run.
Hi, love this plugin! Just wanted to see if there was an API available for extracting the total startup time returned from the Profile UI. I want to just display this value when Neovim starts.