【发布时间】:2015-12-01 19:28:12
【问题描述】:
我注意到git difftool 非常慢。每次差异调用之间会出现大约 1..2 秒的延迟。
为了对其进行基准测试,我编写了一个自定义 difftool 命令:
#!/bin/sh
echo $0 $1 $2
并在我的~/.gitconfig中配置Git使用这个工具
[diff]
tool = mydiff
[difftool "mydiff"]
prompt = false
cmd = "~/mydiff \"$LOCAL\" \"$REMOTE\""
我在 Git 源代码上对其进行了测试:
$ git clone https://github.com/git/git.git
$ cd git
$ git rev-parse HEAD
1bc8feaa7cc752fe3b902ccf83ae9332e40921db
$ git diff head~10 --stat --name-only | wc -l
23
当我将git difftool 与259b5e6d33 计时时,结果慢得离谱:
$ time git difftool 259b5
mydiff /dev/null Documentation/RelNotes/2.6.3.txt
...
mydiff /tmp/mY2T6l_upload-pack.c upload-pack.c
real 0m10.381s
user 0m1.997s
sys 0m6.667s
通过尝试更简单的脚本,它会更快:
$ time git diff --name-only --stat 259b5 | xargs -n1 -I{} sh -c 'git show 259b5:{} > {}.tmp && ~/mydiff {} {}.tmp'
mydiff Documentation/RelNotes/2.6.3.txt Documentation/RelNotes/2.6.3.txt.tmp
mydiff upload-pack.c upload-pack.c.tmp
real 0m1.149s
user 0m0.472s
sys 0m0.821s
我错过了什么?
这是我得到的结果
| Cygwin | Debian | Ubuntu | Method |
| ------ | ------ | ------ | -------- |
| 10.381 | 2.620 | 0.580 | difftool |
| 1.149 | 0.567 | 0.210 | custom |
对于Cygwin 结果,我测量了在git-difftool 中花费的2.8 秒和在git-difftool--helper 中花费的7.5 秒。后者有 98 行长。我不明白为什么这么慢。
【问题讨论】:
-
嗨。我面临着同样的问题。你有没有得到关于为什么 git difftool 这么慢的答案?
-
不,我还没有找到任何解决方案。
-
嗨。我想你可能会对这个问题在 Git 2.8.1 for Windows 中得到修复感兴趣。请参阅github.com/git-for-windows/git/issues/711。
-
我在 mingw64 中看到与 Git 2.8.1 完全相同的行为。另外,@jeyoung 您链接的问题是 vim 集成。也许是不同的问题?
标签: git cygwin mingw benchmarking git-difftool