diff --git a/scripts/nu-test b/scripts/nu-test deleted file mode 100755 index 7a28f5e..0000000 --- a/scripts/nu-test +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/env nu - -def main [] { - [ - nvim-baseline - nvim - ] - | each {|vim| - run-multiple-profiles $vim - } -} - -def run-multiple-profiles [vim] { - 1..10 - | each { - profile-a-lazy-nvim $vim - } - | insert lazytime {|run| $run.times.LazyDone - $run.times.LazyStart} - | { - vim: $vim - total_plugins: $in.0.count - loaded_plugins: $in.0.loaded - sample_size: ($in | length) - avg: ($in.lazytime | math avg) - dev: ($in.lazytime | math stddev) - max: ($in.lazytime | math max) - min: ($in.lazytime | math min) - median: ($in.lazytime | math median) - } -} - -def profile-a-lazy-nvim [vim] { - with-env [NVIM_APPNAME $vim] { - do { - ^nvim --headless +'lua =require("lazy.stats").stats()' +q - } - | complete - } - | get stderr - | lines - | where $it !~ ^\w - | str join (char newline) - | str replace --all ' =' ':' - | from nuon -} diff --git a/scripts/profile-nvim b/scripts/profile-nvim new file mode 100755 index 0000000..8fe19b6 --- /dev/null +++ b/scripts/profile-nvim @@ -0,0 +1,77 @@ +#!/bin/env nu + +def main [] { + let baselineProfile = 'nvim-baseline' + try-create-baseline-nvim $baselineProfile + [ + $baselineProfile + nvim + ] + | each {|vim| + run-multiple-profiles $vim + } +} + +def try-create-baseline-nvim [profile] { + let directory = $'~/.config/($profile)' | path expand + $directory + | path exists + | if not $in { + create-baseline-nvim $directory + } +} + +def create-baseline-nvim [directory] { + mkdir $directory + let init = $directory | path join init.lua + + "~/.local/share/nvim/lazy/lazy.nvim" + | path expand + | $"vim.opt.rtp:prepend\('($in)') + require\('lazy').setup\({})" + | save -f $init +} + +def run-multiple-profiles [vim] { + let output_file = "output.txt" + 1..10 + | each { + run-vim-profile $vim $output_file + } + + parse-output-file $output_file + | { + vim: $vim + total_plugins: $in.0.count + loaded_plugins: $in.0.loaded + sample_size: ($in | length) + avg: ($in.startuptime | math avg) + dev: ($in.startuptime | math stddev) + max: ($in.startuptime | math max) + min: ($in.startuptime | math min) + median: ($in.startuptime | math median) + } +} + +def run-vim-profile [vim output_file] { + with-env {NVIM_APPNAME: $vim} { + $":redir >> ($output_file) + :lua =require\('lazy.stats').stats\() + ZQ" + | ^nvim -s - /dev/null + } +} + +def parse-output-file [output_file] { + let results = open $output_file + rm $output_file + + $results + | lines + | where $it !~ ^\w + | prepend '[' + | append ']' + | str join (char newline) + | str replace --all ' =' ':' + | from nuon +}