Skip to content

Commit

Permalink
feat: add statusline generator benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
famiu committed Sep 17, 2021
1 parent 7eb360e commit 3b23c73
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
13 changes: 8 additions & 5 deletions benchmark/benchmark.lua → benchmark/startup.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
-- Feline benchmark test
-- Feline startup benchmark test
-- Make sure you have feline.nvim and its dependencies installed and
-- run from Feline top-level directory using:
-- env AK_PROFILER=1 nvim -u benchmark/benchmark.lua > /dev/null 2>&1 | less
-- env AK_PROFILER=1 nvim -u benchmark/startup.lua > /dev/null 2>&1 | less

local opt = vim.opt
local fn = vim.fn

-- Automatically install profiler.nvim if it doesn't exist
if not pcall(require, 'profiler') then
local install_path = '/tmp/nvim/site/pack/feline/start/profiler.nvim'

vim.opt.packpath:append('/tmp/nvim/site')
opt.packpath:append('/tmp/nvim/site')

if vim.fn.isdirectory(install_path) == 0 then
vim.fn.system({'git', 'clone', 'https://github.com/norcalli/profiler.nvim', install_path})
if fn.isdirectory(install_path) == 0 then
fn.system({'git', 'clone', 'https://github.com/norcalli/profiler.nvim', install_path})
end
end

Expand Down
31 changes: 31 additions & 0 deletions benchmark/statusline.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-- Feline statusline generation benchmark test
-- Start Neovim with Feline installed and configured and source this file using the luafile command

local opt = vim.opt
local fn = vim.fn

-- Automatically install plenary.nvim if it doesn't exist
if not pcall(require, 'plenary.benchmark') then
local install_path = '/tmp/nvim/site/pack/feline/start/plenary.nvim'

opt.packpath:append('/tmp/nvim/site')

if fn.isdirectory(install_path) == 0 then
fn.system({'git', 'clone', 'https://github.com/nvim-lua/plenary.nvim', install_path})
end
end

-- Start benchmark
local benchmark = require('plenary.benchmark')
local statusline_generator = require('feline').statusline

benchmark("Feline statusline generation benchmark", {
runs = 1000,
fun = {
{
"Generating statusline",
statusline_generator
}
}
})

0 comments on commit 3b23c73

Please sign in to comment.