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

Re: profile prompt rendering time



On Jul 13, 11:17am, Filipe Silva wrote:
}
} I'm talking about the time that it takes for zsh to give me another
} prompt once that it is fully loaded. In other words, I want to achieve
} this:
} 
} ~ $ ls (when i hit enter, start counting)
} code/ notes/ file.txt
} ~ $ (stop counting when this prompt appears. show me elapsed time)

By your literal example, you would be getting a timing that includes
the execution of "ls".  Is that really what you want?

Assuming not, probably the closest you can get is to declare

    float SECONDS

and then print $SECONDS at the end of your precmd function, and at the
beginning of the zle-line-init widget call "zle -M $SECONDS".

However, I don't know how to explain in detail how to accomplish that
because you mention using plugins and I have no way to know whether
those plugins have co-opted precmd or zle-line-init for other uses.

If you really do want to include the execution time of "ls", then
print $SECONDS at the end of preexec instead of at the end of precmd.

Just to demonstrate, here's the output from precmd/zle-line-init with
an otherwise virgin "zsh -f" on my desktop:

torch% echo start
start
4.800639270e+02                                                                 
torch% 
4.800641060e+02



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