profiling - 如何分析 Fish shell init?
问题描述
当我启动一个新的 shell 时,有没有办法查看每件事花费了多少时间(例如,一些正在运行的函数等)。
是否可以?
我能想到的唯一帮助就是做以下事情:
~
λ time fish -i -c exit
________________________________________________________
Executed in 142.29 millis fish external
usr time 76.19 millis 68.00 micros 76.12 millis
sys time 61.52 millis 469.00 micros 61.05 millis
然后试图把东西拿出来重新测量……虽然不理想。
解决方案
Fish 有一个内置的分析功能。
从 fish 3.2 开始,它必须--profile
只分析您给出的命令并--profile-startup
分析启动时间,然后才能--profile
将两者一起分析。
使用喜欢
fish --profile-startup /tmp/fish.profile -i -c exit
这将创建一个名为“/tmp/fish.profile”的文件,看起来像
Time Sum Command
415 2505 > builtin source /usr/share/fish/config.fish
15 15 -> set -g IFS \n\ \t
6 6 -> set -qg __fish_added_user_paths
4 4 -> set -g __fish_added_user_paths
1 4 -> if not set -q __fish_initialized...
3 3 --> not set -q __fish_initialized
3 3 -> function __fish_default_command_not_found_handler...
4 72 -> if status --is-interactive...
第一列是命令本身所用的时间(以微秒为单位,因此 1000000 是 1s),第二列是它及其所有部分(包括函数调用和命令替换)所用的时间,第三列是命令加上指示如何这是在调用堆栈的深处。
要查看最大的时间投资sort -nk2 /tmp/fish.profile
是有用的 - 这按第二列排序,因此它将最后显示大票项目(即最接近下一个提示)。
请注意,这也显示了 fish 的内部启动 -set -g IFS
例如,它是 fish 内部的东西,但它往往很快,所以它不会很突出。
推荐阅读
- ios - 在 iOS 上为图像渲染 *only* 阴影
- javascript - 列表项在单击链接或重新加载/刷新页面时保持打开状态
- directory - 在 UiPath StudioX 中运行移动活动时无法创建动态文件夹?
- rasa - RASA:如何建立混合主动的对话?
- solidity - Chainlink api实现功能耗尽gas
- python - 从 h5py 中的参考文件中提取文本
- dynamic - MS Access - 根据组合框在查询中设置字段名称
- android - 我无法在北极狐中复制。当我试图复制任何东西时,我看到了一个黑色的东西
- java - 寻找抽象方法的实现
- unity3d - Unity 3D 中的无限地图