Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Timing function execution



Hello again, all!

It looks like "time" is a reserved keyword, but it is not possible to use "time" on shell functions (and /usr/bin/time cannot be used for obvious reasons).

What is the appropriate way to benchmark / log the execution time of a function?

    $ which -a time
    time: shell reserved word
    /usr/bin/time

    $ foo() { sleep 1; echo hello }

    $ foo
    hello

    $ time foo
    hello

Zach Riggle



Messages sorted by: Reverse Date, Date, Thread, Author