Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import-Module Jump-Location slows down powershell 5 times on burning console benchmark #17

Closed
vors opened this issue Sep 18, 2014 · 6 comments
Assignees

Comments

@vors
Copy link
Collaborator

@vors vors commented Sep 18, 2014

Benchmark: http://www.leeholmes.com/blog/2005/12/18/burn-console-optimized-and-ready-for-marshmallows/

Drops from 54 fps to 10 fps

This most likely totally related to using break-point on $pwd for tracking directory changes. We need to find a better way to achieve same thing.

@tkellogg
Copy link
Owner

@tkellogg tkellogg commented Sep 18, 2014

yeah, I got the $pwd trick from some PowerShell experts off of Stack Overflow. If there's a newer/better way to do it, I'm all ears.

@tkellogg
Copy link
Owner

@tkellogg tkellogg commented Sep 19, 2014

I thought about this last night while I wasn't sleeping and remembered this line:

https://github.com/tkellogg/Jump-Location/blob/master/Jump.Location/CommandController.cs#L82

I believe the Thread.Sleep(10) is probably too short. Raise it to like 100 or 1000 or something.

@vors
Copy link
Collaborator Author

@vors vors commented Sep 19, 2014

I don't think that's the reason. @lzybkr (author of PSReadLine and a lot of PS internals) pointed out the problem with Set-PSBreakpoint: it turns off optimizations. I will work on it on weekend. Changing hook from BP to prompt will also solve #15. You remember, prompt was the second suggestion on the original stackoverflow question =) http://stackoverflow.com/questions/11788133/how-to-detect-how-long-a-user-stays-in-one-location-in-powershell/11813545#11813545

@vors
Copy link
Collaborator Author

@vors vors commented Sep 21, 2014

Remark: #24 doesn't exactly solve #15.
It solves motivation scenario (POSH git + Jump-Location) for #15.

@vors vors self-assigned this Sep 22, 2014
@oising
Copy link

@oising oising commented Sep 23, 2014

Here's another way to monitor the $pwd variable:

PS C:\local> $n = 0; (gv pwd).attributes.Add((new-object ValidateScript { $global:n++; $true }))
PS C:\local> $n
1
PS C:\local> $n
1
PS C:\local> cd poke
PS C:\local\poke> $n
2

If you want to do this programmatically with a custom attribute, derive from the argument transformation attribute. Obviously I'm not saying use global variables to track state, but this is just a demonstration of how the script is only invoked when $pwd changes.

@vors
Copy link
Collaborator Author

@vors vors commented Sep 23, 2014

@oising that's a great trick! Thank you for sharing it.
I also trying to address Scott's scenario with posh-git #15, so OnIdle seems more appropriate for that. It will not track anything inside the scripts.

@vors vors closed this in #24 Sep 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.