zsh-users
 help / color / mirror / code / Atom feed
* "Profiling" my startup scripts
@ 2011-11-23 21:04 Daniel Serodio (lists)
  2011-11-23 21:20 ` Mikael Magnusson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Daniel Serodio (lists) @ 2011-11-23 21:04 UTC (permalink / raw)
  To: zsh-users

I have somewhat complex .zshrc and .zshenv startup scripts that I've 
improved over the years, running Linux. Now I'm using OSX and something 
in these scripts is taking more time than usual, and I'd like to 
"profile" them, ie. find out how long each step takes.

My first idea was to add a $(date) execution to PS4, but I found that it 
doesn't work in zsh (it works in bash).

Do you have any suggestions about a better way to profile my startup 
scripts?

Also, would you add this feature (command execution substitution in PS4) 
to zsh?

Thanks in advance,
Daniel Serodio


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: "Profiling" my startup scripts
  2011-11-23 21:04 "Profiling" my startup scripts Daniel Serodio (lists)
@ 2011-11-23 21:20 ` Mikael Magnusson
  2011-11-23 21:25 ` Dan Nelson
  2011-11-23 22:04 ` Benjamin R. Haskell
  2 siblings, 0 replies; 4+ messages in thread
From: Mikael Magnusson @ 2011-11-23 21:20 UTC (permalink / raw)
  To: Daniel Serodio (lists); +Cc: zsh-users

On 23 November 2011 22:04, Daniel Serodio (lists)
<daniel.lists@mandic.com.br> wrote:
> I have somewhat complex .zshrc and .zshenv startup scripts that I've
> improved over the years, running Linux. Now I'm using OSX and something in
> these scripts is taking more time than usual, and I'd like to "profile"
> them, ie. find out how long each step takes.
>
> My first idea was to add a $(date) execution to PS4, but I found that it
> doesn't work in zsh (it works in bash).
>
> Do you have any suggestions about a better way to profile my startup
> scripts?
>
> Also, would you add this feature (command execution substitution in PS4) to
> zsh?

Running $(date) on every line of your rc is probably a bad idea, but
you can setopt promptsubst to enable it. Rather than running date,
though, it's a much better idea to run typeset -F 3 SECONDS and use
$SECONDS in PS4 (this also needs promptsubst).

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: "Profiling" my startup scripts
  2011-11-23 21:04 "Profiling" my startup scripts Daniel Serodio (lists)
  2011-11-23 21:20 ` Mikael Magnusson
@ 2011-11-23 21:25 ` Dan Nelson
  2011-11-23 22:04 ` Benjamin R. Haskell
  2 siblings, 0 replies; 4+ messages in thread
From: Dan Nelson @ 2011-11-23 21:25 UTC (permalink / raw)
  To: Daniel Serodio (lists); +Cc: zsh-users

In the last episode (Nov 23), Daniel Serodio (lists) said:
> I have somewhat complex .zshrc and .zshenv startup scripts that I've
> improved over the years, running Linux.  Now I'm using OSX and something
> in these scripts is taking more time than usual, and I'd like to "profile"
> them, ie.  find out how long each step takes.
> 
> My first idea was to add a $(date) execution to PS4, but I found that it 
> doesn't work in zsh (it works in bash).
> 
> Do you have any suggestions about a better way to profile my startup 
> scripts?
> 
> Also, would you add this feature (command execution substitution in PS4) 
> to zsh?

You need the PROMPT_SUBST option for $() to work in prompt strings.  But
it's a lot more efficient to just have zsh print the time directly, without
forking a subshell: PS4="%D %* "

-- 
	Dan Nelson
	dnelson@allantgroup.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: "Profiling" my startup scripts
  2011-11-23 21:04 "Profiling" my startup scripts Daniel Serodio (lists)
  2011-11-23 21:20 ` Mikael Magnusson
  2011-11-23 21:25 ` Dan Nelson
@ 2011-11-23 22:04 ` Benjamin R. Haskell
  2 siblings, 0 replies; 4+ messages in thread
From: Benjamin R. Haskell @ 2011-11-23 22:04 UTC (permalink / raw)
  To: Daniel Serodio (lists); +Cc: zsh-users

On Wed, 23 Nov 2011, Daniel Serodio (lists) wrote:

> I have somewhat complex .zshrc and .zshenv startup scripts that I've 
> improved over the years, running Linux. Now I'm using OSX and 
> something in these scripts is taking more time than usual, and I'd 
> like to "profile" them, ie.  find out how long each step takes.
>
> My first idea was to add a $(date) execution to PS4, but I found that 
> it doesn't work in zsh (it works in bash).
>
> Do you have any suggestions about a better way to profile my startup 
> scripts?

If you're looking for differences that could be spotted by $(date) (so, 
things that take multiple seconds to run), you might try just running 
with tracing enabled:

zsh -x

The commands are output before they're run, so if you end up with:

+.zshrc:123> some long running command

You can probably just eyeball it.

-- 
Best,
Ben


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-23 22:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-23 21:04 "Profiling" my startup scripts Daniel Serodio (lists)
2011-11-23 21:20 ` Mikael Magnusson
2011-11-23 21:25 ` Dan Nelson
2011-11-23 22:04 ` Benjamin R. Haskell

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).