Skip to content

Performance Comparison

Roger Bongers edited this page Sep 1, 2023 · 5 revisions
Plugin Redraw time (statusline only) Redraw time (statusline + tabline)
vim-crystalline 0.000506s 0.000617s
vim-airline 0.001072s 0.001368s
lightline.vim 0.000414s 0.000645s
vanilla vim 0.000333s 0.000327s

Importance of Performance

Statuslines and tablines can be a general source of slowness in Vim. The statusline must be set for every window on every update. The tabline gets slower for every tab added.

Some statuslines auto-update multiple times per second by default, which can cause lag. vim-crystalline only updates in response to autocommands. This is not tested here.

Note that performance is not the main goal of vim-crystalline. Its only goal is to let you build your own statusline. vim-crystalline only aims to be "fast enough".

Accuracy of the Test Results

It is impossible to test every situation where a statusline can change. Results should be considered rough estimates. You are encouraged to try plugins yourself.

If you have any suggestion to make these tests more accurate, please post an issue.

Methodology

All plugins have a similar configuration for a fair comparison.

The function crystalline#Profile(10000) was used to retrieve results. This redraws the screen 10000 times and averages the performance.

Tests were run with 4 windows open and 4 tabs open.

vim-crystalline .vimrc

function! g:CrystallineStatuslineFn(winnr)
  let l:curr = a:winnr == winnr()
  let l:s = ''

  if l:curr
    let l:s .= crystalline#ModeSection(0, 'A', 'B')
  else
    let l:s .= crystalline#HiItem('Fill')
  endif
  let l:s .= ' %f%h%w%m%r '
  if l:curr
    let l:s .= crystalline#Sep(0, 'B', 'Fill')
  endif

  let l:s .= '%='
  if l:curr
    let l:s .= crystalline#Sep(1, 'Fill', 'B') . ' %{&paste ?"PASTE ":""}%{&spell?"SPELL ":""}'
    let l:s .= crystalline#Sep(1, 'B', 'A')
  endif
  if winwidth(a:winnr) > 80
    let l:s .= ' %{&ft} %l/%L %2v '
  else
    let l:s .= ' '
  endif

  return l:s
endfunction

function! g:CrystallineTablineFn()
  return crystalline#DefaultTabline({ 'enable_sep': 1 })
endfunction

set laststatus=2
let g:crystalline_auto_prefix_groups = 1

" disable tabline
delfunction CrystallineTablineFn
set showtabline=0
" enable tabline
" set showtabline=2

call plug#begin()
Plug 'rbong/vim-crystalline'
call plug#end()

vim-airline .vimrc

" follow https://github.com/vim-airline/vim-airline#performance
let g:airline_highlighting_cache = 1
let g:airline_extensions = []

" disable some info to make it more similar to other plugins
let g:airline#extensions#tabline#show_tab_count = 0
let airline#extensions#tabline#show_splits = 0

let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline#extensions#tabline#left_sep = g:airline_left_sep
let g:airline#extensions#tabline#left_alt_sep = g:airline_left_alt_sep
let g:airline#extensions#tabline#right_sep = g:airline_right_sep
let g:airline#extensions#tabline#right_alt_sep = g:airline_right_alt_sep

" enable tabline
" call add(g:airline_extensions, 'tabline')

call plug#begin()
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'rbong/vim-crystalline'
call plug#end()

lightline.vim .vimrc

set laststatus=2

" disable tabline
set showtabline=0
" enable tabline
" set showtabline=2

let g:lightline = {
            \ 'separator': { 'left': '', 'right': '' },
            \ 'subseparator': { 'left': '', 'right': '' },
            \ }

call plug#begin()
Plug 'itchyny/lightline.vim'
Plug 'rbong/vim-crystalline'
call plug#end()

vanilla .vimrc

set laststatus=2

" disable tabline
set showtabline=0
" enable tabline
" set showtabline=2

call plug#begin()
Plug 'rbong/vim-crystalline'
call plug#end()
Clone this wiki locally