ZSH: How to time a block of code?

Viewed 9390

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

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?

4 Answers
Related