git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Silly Question About Timing

From
SRSeth Robertson <in-gitvger@baka.org>
Date
Feb 9, 2012, 21:16 UTC
Message-ID
<201202092116.q19LGnTY024797@no.baka.org>
In-Reply-To
<CAE1pOi1+FQNoPZ_P-fmFx-YhnUYzMQT=6zh3s-OyT71vcDm=wQ@mail.gmail.com>
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
Previous: Hilco WijbengaNext: Hilco Wijbenga
Message 2 of 4 in “Silly Question About Timing”
  1. Hilco WijbengaFeb 9, 2012
  2. Seth RobertsonFeb 9, 2012
  3. Hilco WijbengaFeb 9, 2012
  4. Frans KlaverFeb 9, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.