Skip to content

Commit

Permalink
docs: add perf intro for hlchunk
Browse files Browse the repository at this point in the history
  • Loading branch information
shellRaining committed Jul 13, 2024
1 parent 0130f1b commit d5e4580
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,27 @@
<p align='center'>
<b>English</b> | <a href="./README.zh-CN.md">简体中文</a>
</p>
## What can this plugin do

## notice!!!
Similar to [indent-blankline](https://github.com/lukas-reineke/indent-blankline.nvim), this plugin can highlight the indent line, and highlight the code chunk according to the current cursor position.

There have been many recent changes. If you encounter any bugs, please feel free to raise an issue. I will improve the code clarity and documentation in the future.
## plugin performance

## What can this plugin do
Using `profile.nvim` for performance analysis, all experiments were conducted on macOS with alacritty, Neovim window height was 66 lines, the code file was `typescript.js`, starting from the first line to the five hundredth line. The average rendering time per render was `0.7ms`.

Similar to [indent-blankline](https://github.com/lukas-reineke/indent-blankline.nvim), this plugin can highlight the indent line, and highlight the code chunk according to the current cursor position.
I did a lot of work to minimize rendering time as much as possible

1. Asynchronous rendering to reduce stuttering

2. Using C functions to speed up some function calls

3. Caching extmarks for each line as much as possible to reduce indentation calculations

4. Using throttle functions to batch the rendering process as much as possible

If you want to reduce the sudden stuttering when scrolling the window, maybe you will like `hlchunk.nvim`~

For detailed optimization work, you can see my blog (written in Chinese): [https://www.shellraining.top/docs/tools/hlchunk/profile.html](https://www.shellraining.top/docs/tools/hlchunk/profile.html)

## Brief introduction

Expand Down
18 changes: 14 additions & 4 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@
<p align='center'>
<a href="./README.md">English</a> | <b>简体中文</b>
</p>
## 这个插件可以做什么

## 注意!!!
[indent-blankline.nvim](https://github.com/lukas-reineke/indent-blankline.nvim) 类似,这个插件可以用来高亮缩进线,并且还可以根据当前光标所处的位置,高亮所在代码块.

最近代码发生了很多变动。如果您遇到任何 bug,请随时提出 issue。我将在未来改进代码清晰度和文档。
## 插件性能

## 这个插件可以做什么
使用 `profile.nvim` 进行性能分析,所有实验均是在 macOS 上的 alacritty 进行,Neovim 窗口高度为 66 行,代码文件是 `typescript.js`,从首行开始,到五百行结束。平均每次渲染耗时 `0.7ms`

[indent-blankline.nvim](https://github.com/lukas-reineke/indent-blankline.nvim) 类似,这个插件可以用来高亮缩进线,并且还可以根据当前光标所处的位置,高亮所在代码块.
我做了很多工作来尽可能缩短渲染耗时

1. 异步渲染,减少卡顿
2. 使用 c 函数,加快部分函数调用
3. 尽可能缓存每行的 extmark,减少缩进计算
4. 使用节流函数来尽可能批处理渲染过程

如果你希望能够减少滚动窗口时候突如其来的卡顿感,也许你会喜欢上 `hlchunk.nvim`~

具体的优化工作你可以看我的博客 [https://www.shellraining.top/docs/tools/hlchunk/profile.html](https://www.shellraining.top/docs/tools/hlchunk/profile.html)

## 简要概述

Expand Down

0 comments on commit d5e4580

Please sign in to comment.