ZSH:如何计时code块? [英] ZSH: How to time a block of code?

查看:108
本文介绍了ZSH:如何计时code块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在bash中,我可以写一个包含类似这样的脚本:

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 blah blah"

} } 2> $LOGFILE

在ZSH相当于code不工作,我无法弄清楚如何使它为我工作。这code ++工程,但我不知道究竟如何得到它来包装多个命令。

In ZSH the equivalent code does not work and I can not figure out how to make it work for me. This code works but I don't exactly know how to get it to wrap multiple commands.

{ time echo "something" } 2>&1

我知道我可以创建一个新的脚本,并把命令有时间再执行正常,但有没有办法做到这一点无论是使用功能或类似的方法上面的庆典?

I know I can create a new script and put the commands in there then time the execution properly, but is there a way to do it either using functions or a similar method to the bash above?

推荐答案

请尝试以下操作来代替:

Try the following instead:

{ time ( echo hello ; sleep 10s;  echo hola ; ) } 2>&1 

这篇关于ZSH:如何计时code块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆