作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 shell 启动时间似乎太长了。有什么方法可以对其进行分析,以便我可以找出是什么导致它速度如此之慢?
最佳答案
尝试将其添加到文件的开头:
# set the trace prompt to include seconds, nanoseconds, script name and line number
# This is GNU date syntax; by default Macs ship with the BSD date program, which isn't compatible
PS4='+$(date "+%s:%N") %N:%i> '
# save file stderr to file descriptor 3 and redirect stderr (including trace
# output) to a file with the script's PID as an extension
exec 3>&2 2>/tmp/startlog.$$
# set options to turn on tracing and expansion of commands contained in the prompt
setopt xtrace prompt_subst
最后是这个:
# turn off tracing
unsetopt xtrace
# restore stderr to the value saved in FD 3
exec 2>&3 3>&-
并且您应该获得详细的日志,显示每行执行的 epoch_second.nanosecond 时间。请注意,GNU date
(和操作系统支持)需要纳秒输出。
编辑:
添加评论
编辑2:
如果您有 zsh 4.3.12 或更高版本,您应该能够像这样设置 PS4
,而不是使用 date
命令:
zmodload zsh/datetime
setopt promptsubst
PS4='+$EPOCHREALTIME %N:%i> '
它应该在 Linux 和 OS X 上工作,为您提供纳秒精度。
关于profiling - 我可以分析我的 .zshrc/.zshenv 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4351244/
我的 shell 启动时间似乎太长了。有什么方法可以对其进行分析,以便我可以找出是什么导致它速度如此之慢? 最佳答案 尝试将其添加到文件的开头: # set the trace prompt to i
让 rbenv 加载 Ruby v 2.3.0 让我做了一场噩梦。在将“eval“$(rbenv init -)”添加到我的 .zshrc 文件后,我终于让它显示出来了。但是,现在我在重新启动时会在终
我的设置是 arch linux 中的 zsh 5.0.5 我在 .zshenv 中设置了如下的 PATH 变量 typeset -U path path=(~/bin $path) DW=$HOME
我是一名优秀的程序员,十分优秀!