{"thread":{"id":"29584","subject":"Silly Question About Timing","startedAt":"2012-02-09T21:10:58Z","lastAt":"2012-02-09T21:54:32Z","messageCount":4,"participants":["Hilco Wijbenga","Seth Robertson","Frans Klaver"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"184267","messageId":"CAE1pOi1+FQNoPZ_P-fmFx-YhnUYzMQT=6zh3s-OyT71vcDm=wQ@mail.gmail.com","threadId":"29584","inReplyTo":null,"subject":"Silly Question About Timing","fromName":"Hilco Wijbenga","fromEmail":"hilco.wijbenga@gmail.com","sentAt":"2012-02-09T21:10:58Z","receivedAt":"2012-02-09T21:10:58Z","isPatch":false,"sender":{"key":"hilco.wijbenga@gmail.com","avatar":null},"body":"Hi all,\n\nThis is a bit silly but I'm trying to time how long it takes to enter\na Git controlled directory. I guess this is more of a GNU/Linux\nquestion then anything else.\n\nI've noticed that entering a Git controlled project directory takes\nquite some time so I wanted to measure exactly how much (it's the\nprompt I'm using that's taking the time, I suspect). I first tried (a\nbit naive, I admit :-) )\n\ntime cd my-project\n\nThis doesn't work of course. Obviously, writing a script doesn't work\neither because then the prompt isn't calculated. Next I tried\n\ndate +%H:%M:%S.%N ; cd my-project-abc ; date +%H:%M:%S.%N\n\nbut, surprisingly (to me), that doesn't work either. It simply prints\nthe two timestamps and *then* does the cd (or, at least, that's how it\nseems to behave).\n\nSo how would one do this? :-)\n\nCheers,\nHilco\n\nP.S. This slow cd is only the first time, afterwards things have been cached.\n"},{"id":"184268","messageId":"201202092116.q19LGnTY024797@no.baka.org","threadId":"29584","inReplyTo":"CAE1pOi1+FQNoPZ_P-fmFx-YhnUYzMQT=6zh3s-OyT71vcDm=wQ@mail.gmail.com","subject":"Re: Silly Question About Timing","fromName":"Seth Robertson","fromEmail":"in-gitvger@baka.org","sentAt":"2012-02-09T21:16:49Z","receivedAt":"2012-02-09T21:16:49Z","isPatch":false,"sender":{"key":"in-gitvger@baka.org","avatar":null},"body":"\nIn message <CAE1pOi1+FQNoPZ_P-fmFx-YhnUYzMQT=6zh3s-OyT71vcDm=wQ@mail.gmail.com>, Hilco Wijbenga writes:\n\n    I've noticed that entering a Git controlled project directory takes\n    quite some time so I wanted to measure exactly how much (it's the\n    prompt I'm using that's taking the time, I suspect). I first tried (a\n    bit naive, I admit :-) )\n\n    time cd my-project\n\nYour confusion is because you are measuring the wrong thing.  I'm\nassuming, here, that you have a shell prompt which is giving you all\nsorts of status about the git repository.  The \"cd\" operation is\ninstantaneous, it is the shell attempting to compute the new prompt\nwhich is slow.\n\nExactly how your shell does this is shell dependent, but you might\nwant to look at your setting of $PROMPT_COMMAND.  Then you can test it\nby running something like:\n\ntime sh -c \"cd git-directory; $PROMPT_COMMAND\"\n\n\t\t\t\t\t-Seth Robertson\n"},{"id":"184272","messageId":"CAE1pOi14LW6ayNiRd2KogKZn2zLMbRsTS1kkMFgFBtx5J=yFNA@mail.gmail.com","threadId":"29584","inReplyTo":"201202092116.q19LGnTY024797@no.baka.org","subject":"Re: Silly Question About Timing","fromName":"Hilco Wijbenga","fromEmail":"hilco.wijbenga@gmail.com","sentAt":"2012-02-09T21:48:25Z","receivedAt":"2012-02-09T21:48:25Z","isPatch":false,"sender":{"key":"hilco.wijbenga@gmail.com","avatar":null},"body":"On 9 February 2012 13:16, Seth Robertson <in-gitvger@baka.org> wrote:\n>\n> In message <CAE1pOi1+FQNoPZ_P-fmFx-YhnUYzMQT=6zh3s-OyT71vcDm=wQ@mail.gmail.com>, Hilco Wijbenga writes:\n>\n>    I've noticed that entering a Git controlled project directory takes\n>    quite some time so I wanted to measure exactly how much (it's the\n>    prompt I'm using that's taking the time, I suspect). I first tried (a\n>    bit naive, I admit :-) )\n>\n>    time cd my-project\n>\n> Your confusion is because you are measuring the wrong thing.  I'm\n> assuming, here, that you have a shell prompt which is giving you all\n> sorts of status about the git repository.  The \"cd\" operation is\n> instantaneous, it is the shell attempting to compute the new prompt\n> which is slow.\n\nYes, exactly.\n\n> Exactly how your shell does this is shell dependent, but you might\n> want to look at your setting of $PROMPT_COMMAND.  Then you can test it\n> by running something like:\n>\n> time sh -c \"cd git-directory; $PROMPT_COMMAND\"\n\nI tried that and it's still instantaneous.\n\nThe culprit is\n\nexport PS1='\\[\\033[01;32m\\]\\u@\\h\\[\\033[01;34m\\] \\w \\W$(__git_ps1 \"\n(%s)\")\\$\\[\\033[00m\\] '\n\nbut I can't get that to run. Simply running\n\necho $PS1\n\ndoesn't work and I have been unable to get the __git_ps1 part to do anything.\n"},{"id":"184275","messageId":"op.v9fls6op0aolir@keputer.lokaal","threadId":"29584","inReplyTo":"CAE1pOi14LW6ayNiRd2KogKZn2zLMbRsTS1kkMFgFBtx5J=yFNA@mail.gmail.com","subject":"Re: Silly Question About Timing","fromName":"Frans Klaver","fromEmail":"fransklaver@gmail.com","sentAt":"2012-02-09T21:54:32Z","receivedAt":"2012-02-09T21:54:32Z","isPatch":false,"sender":{"key":"fransklaver@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1876483?v=4"},"body":"On Thu, 09 Feb 2012 22:48:25 +0100, Hilco Wijbenga  \n<hilco.wijbenga@gmail.com> wrote:\n\n> ... and I have been unable to get the __git_ps1 part to do anything.\n\nI get the following on msysgit:\n\n/c/msysgit (devel) $ time __git_ps1\n(devel)\nreal    0m0.406s\nuser    0m0.136s\nsys     0m0.107s\n\nWould be odd if that doesn't work on Linux.\n"}]}