20 个版本
0.3.5 | 2023年10月25日 |
---|---|
0.3.4 | 2022年12月19日 |
0.3.3 | 2021年5月10日 |
0.3.2 | 2019年11月25日 |
0.1.10 | 2018年3月20日 |
#285 在 开发工具
41KB
801 行
ptags
适用于 git 仓库的并行 universal-ctags 包装器
描述
ptags 是一个 universal-ctags 包装器,具有以下功能。
- 仅搜索 git 跟踪文件(支持
.gitignore
) - 并行调用
ctags
命令以加速- 比 universal-ctags 快 5 倍以上
安装
下载二进制文件
从 发布页面 下载,并解压缩到 PATH 目录中。
Arch Linux
您可以从 AUR 安装。
如果您使用 yay
,可以按照以下方式安装
yay -S ptags // latest tagged version
yay -S ptags-git // current master of git repo
Cargo
您可以通过 cargo 安装。
cargo install ptags
要求
ptags 使用 ctags
和 git
命令。测试的版本如下。
命令 | 版本 |
---|---|
ctags |
Universal Ctags 0.0.0(f9e6e3c1) / Exuberant Ctags 5.8 |
git |
git 版本 2.14.2 |
git-lfs |
git-lfs/2.3.3 |
用法
ptags 0.1.12-pre
dalance@gmail.com
A parallel universal-ctags wrapper for git repository
USAGE:
ptags [FLAGS] [OPTIONS] [--] [DIR]
FLAGS:
--config Generate configuration sample file
--exclude-lfs Exclude git-lfs tracked files
-h, --help Prints help information
--include-ignored Include ignored files
--include-submodule Include submodule files
--include-untracked Include untracked files
-s, --stat Show statistics
--unsorted Disable tags sort
--validate-utf8 Validate UTF8 sequence of tag file
-V, --version Prints version information
-v, --verbose Verbose mode
OPTIONS:
--bin-ctags <bin_ctags> Path to ctags binary [default: ctags]
--bin-git <bin_git> Path to git binary [default: git]
--completion <completion> Generate shell completion file [possible values: bash, fish,
zsh, powershell]
-e, --exclude <exclude>... Glob pattern of exclude file ( ex. --exclude '*.rs' )
-c, --opt-ctags <opt_ctags>... Options passed to ctags
-g, --opt-git <opt_git>... Options passed to git
--opt-git-lfs <opt_git_lfs>... Options passed to git-lfs
-f, --file <output> Output filename ( filename '-' means output to stdout ) [default: tags]
-t, --thread <thread> Number of threads [default: 8]
ARGS:
<DIR> Search directory [default: .]
您可以通过 -c
/--ctags_opt
选项传递给 ctags
的选项,如下所示。
ptags -c --links=no -c --languages=Rust
以下是根据选项搜索的文件类型。 --include-submodule
和 --include_untracked
是互斥的。这是 git ls-files
的限制。可以同时使用任何不包括上述组合的包含/排除选项。
文件类型 | 默认 | --exclude-lfs | --include-ignored | --include-submodule | --include-untracked |
---|---|---|---|---|---|
跟踪 | o | o | o | o | o |
未跟踪 | x | x | x | x | o |
忽略 | x | x | o | x | x |
lfs 跟踪 | o | x | o | o | o |
子模块中 | x | x | x | o | x |
您可以通过以下方式通过 ~/.ptags.toml
覆盖任何默认选项。可以通过 --config
选项生成 ~/.ptags.toml
的完整示例。
thread = 16
bin_ctags = "ctags2"
bin_git = "git2"
基准测试
环境
- CPU: Ryzen Threadripper 1950X
- 内存: 128GB
- 操作系统: CentOS 7.4.1708
数据
名称 | 仓库 | 修订版本 | 文件 | 大小[GB] |
---|---|---|---|---|
source0 | https://github.com/neovim/neovim | f5b0f5e17 | 2370 | 0.1 |
source1 | https://github.com/llvm-mirror/llvm | ddf9edb4020 | 29670 | 1.2 |
source2 | https://github.com/torvalds/linux | 071e31e254e0 | 52998 | 2.2 |
source3 | https://github.com/chromium/chromium | d79c68510b7e | 293205 | 13 |
结果
ptags 的速度比 universal-ctags 快 x5。
命令 | 版本 | source0 | source1 | source2 | source3 |
---|---|---|---|---|---|
ctags-R |
Universal Ctags 0.0.0(f9e6e3c1) | 0.41秒 ( x1 ) | 3.42秒 ( x1 ) | 23.64秒 ( x1 ) | 32.23 ( x1 ) |
ptags-t16 |
ptags 0.1.4 | 0.13秒 ( x3.15 ) | 0.58秒 ( x5.90 ) | 4.24秒 ( x5.58 ) | 7.27秒 ( x4.43 ) |
依赖项
~6–19MB
~231K SLoC