【发布时间】:2021-08-21 20:28:44
【问题描述】:
Git Bash 总体上相当缓慢(比较 WSL/Ubuntu 下 1.082 秒的平均运行时间与 MinTTY 下 4.460 秒的平均运行时间)。我已将高达 1.479 秒的代码缩小到以下代码块:
# Determine if this terminal supports colors
if test -t 1; then
if [[ -n "$(tput colors)" ]] && [[ "$(tput colors)" -ge 8 ]]; then
MY_APP_FMT_SUPPORTED=true
MY_APP_FMT_BOLD="$(tput bold)"
MY_APP_FMT_UNDERLINE="$(tput smul)"
MY_APP_FMT_INVERSE="$(tput smso)"
MY_APP_FMT_BLACK="$(tput setaf 0)"
MY_APP_FMT_RED="$(tput setaf 1)"
MY_APP_FMT_GREEN="$(tput setaf 2)"
MY_APP_FMT_YELLOW="$(tput setaf 3)"
MY_APP_FMT_BLUE="$(tput setaf 4)"
MY_APP_FMT_MAGENTA="$(tput setaf 5)"
MY_APP_FMT_CYAN="$(tput setaf 6)"
MY_APP_FMT_WHITE="$(tput setaf 7)"
MY_APP_FMT_CODE=$MY_APP_FMT_CYAN
# placing it down below so that option -x doesn't cause bad highlighting
# to persist
MY_APP_FMT_CLEAR="$(tput sgr0)"
fi
fi
鉴于我对 *nix 工具在 Windows 上的性能的了解,我怀疑减速是来自所有子 shell。
- 应该这些子shell解释整个减速吗?如果没有,我需要继续研究为什么 Git Bash 仍然缓慢。
- 在保持终端兼容性的同时,有没有更高效的方法来做到这一点?
【问题讨论】:
标签: performance git-bash mintty tput