* Silly Question About Timing
@ 2012-02-09 21:10 Hilco Wijbenga
2012-02-09 21:16 ` Seth Robertson
0 siblings, 1 reply; 4+ messages in thread
From: Hilco Wijbenga @ 2012-02-09 21:10 UTC (permalink / raw
To: Git Users
Hi all,
This is a bit silly but I'm trying to time how long it takes to enter
a Git controlled directory. I guess this is more of a GNU/Linux
question then anything else.
I've noticed that entering a Git controlled project directory takes
quite some time so I wanted to measure exactly how much (it's the
prompt I'm using that's taking the time, I suspect). I first tried (a
bit naive, I admit :-) )
time cd my-project
This doesn't work of course. Obviously, writing a script doesn't work
either because then the prompt isn't calculated. Next I tried
date +%H:%M:%S.%N ; cd my-project-abc ; date +%H:%M:%S.%N
but, surprisingly (to me), that doesn't work either. It simply prints
the two timestamps and *then* does the cd (or, at least, that's how it
seems to behave).
So how would one do this? :-)
Cheers,
Hilco
P.S. This slow cd is only the first time, afterwards things have been cached.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Silly Question About Timing
2012-02-09 21:10 Silly Question About Timing Hilco Wijbenga
@ 2012-02-09 21:16 ` Seth Robertson
2012-02-09 21:48 ` Hilco Wijbenga
0 siblings, 1 reply; 4+ messages in thread
From: Seth Robertson @ 2012-02-09 21:16 UTC (permalink / raw
To: Hilco Wijbenga; +Cc: Git Users
In message <CAE1pOi1+FQNoPZ_P-fmFx-YhnUYzMQT=6zh3s-OyT71vcDm=wQ@mail.gmail.com>, Hilco Wijbenga writes:
I've noticed that entering a Git controlled project directory takes
quite some time so I wanted to measure exactly how much (it's the
prompt I'm using that's taking the time, I suspect). I first tried (a
bit naive, I admit :-) )
time cd my-project
Your confusion is because you are measuring the wrong thing. I'm
assuming, here, that you have a shell prompt which is giving you all
sorts of status about the git repository. The "cd" operation is
instantaneous, it is the shell attempting to compute the new prompt
which is slow.
Exactly how your shell does this is shell dependent, but you might
want to look at your setting of $PROMPT_COMMAND. Then you can test it
by running something like:
time sh -c "cd git-directory; $PROMPT_COMMAND"
-Seth Robertson
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Silly Question About Timing
2012-02-09 21:16 ` Seth Robertson
@ 2012-02-09 21:48 ` Hilco Wijbenga
2012-02-09 21:54 ` Frans Klaver
0 siblings, 1 reply; 4+ messages in thread
From: Hilco Wijbenga @ 2012-02-09 21:48 UTC (permalink / raw
To: Seth Robertson; +Cc: Git Users
On 9 February 2012 13:16, Seth Robertson <in-gitvger@baka.org> wrote:
>
> In message <CAE1pOi1+FQNoPZ_P-fmFx-YhnUYzMQT=6zh3s-OyT71vcDm=wQ@mail.gmail.com>, Hilco Wijbenga writes:
>
> I've noticed that entering a Git controlled project directory takes
> quite some time so I wanted to measure exactly how much (it's the
> prompt I'm using that's taking the time, I suspect). I first tried (a
> bit naive, I admit :-) )
>
> time cd my-project
>
> Your confusion is because you are measuring the wrong thing. I'm
> assuming, here, that you have a shell prompt which is giving you all
> sorts of status about the git repository. The "cd" operation is
> instantaneous, it is the shell attempting to compute the new prompt
> which is slow.
Yes, exactly.
> Exactly how your shell does this is shell dependent, but you might
> want to look at your setting of $PROMPT_COMMAND. Then you can test it
> by running something like:
>
> time sh -c "cd git-directory; $PROMPT_COMMAND"
I tried that and it's still instantaneous.
The culprit is
export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \W$(__git_ps1 "
(%s)")\$\[\033[00m\] '
but I can't get that to run. Simply running
echo $PS1
doesn't work and I have been unable to get the __git_ps1 part to do anything.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Silly Question About Timing
2012-02-09 21:48 ` Hilco Wijbenga
@ 2012-02-09 21:54 ` Frans Klaver
0 siblings, 0 replies; 4+ messages in thread
From: Frans Klaver @ 2012-02-09 21:54 UTC (permalink / raw
To: Seth Robertson, Hilco Wijbenga; +Cc: Git Users
On Thu, 09 Feb 2012 22:48:25 +0100, Hilco Wijbenga
<hilco.wijbenga@gmail.com> wrote:
> ... and I have been unable to get the __git_ps1 part to do anything.
I get the following on msysgit:
/c/msysgit (devel) $ time __git_ps1
(devel)
real 0m0.406s
user 0m0.136s
sys 0m0.107s
Would be odd if that doesn't work on Linux.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-02-09 21:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-09 21:10 Silly Question About Timing Hilco Wijbenga
2012-02-09 21:16 ` Seth Robertson
2012-02-09 21:48 ` Hilco Wijbenga
2012-02-09 21:54 ` Frans Klaver
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).