ZSH: How to time a block of code?

后端 未结 4 594
死守一世寂寞
死守一世寂寞 2020-12-29 04:06

In bash I am able to write a script that contains something like this:

{ time {

#series of commands
echo \"something\"
echo \"another command\"
echo \"blah          


        
4条回答
  •  渐次进展
    2020-12-29 04:44

    If you want to profile your code you have a few alternatives:

    • Time subshell execution like:

      time ( commands ... )

    • Use REPORTTIME to check for slow commands:

      export REPORTTIME=3 # display commands with execution time >= 3 seconds

    • setop xtrace as explained here

    • The zprof module

提交回复
热议问题