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

Faster dotSource implementation for parsing autoload tab-complete #1256

Closed

Conversation

Jackbennett
Copy link
Contributor

This[1] blog post describes a faster method of importing use script into
the powershell session by loading the file contents into memory prior to
letting powershell parse them for auto-complete values.

Reference:

1: https://becomelotr.wordpress.com/2017/02/13/expensive-dot-sourcing/

Testing:

Test #1

dotsource(ms) scriptblock(ms) filename(test data)
18 13 Approve-Script.ps1
6 2 Clear-PrinterQueue.ps1
14 3 ConvertTo-ImageFormat.ps1
9 2 Copy-MultipleItems.ps1
6 2 Enter-RemoteSession.ps1
6 3 Get-CurrentUser.ps1
7 3 Get-LogonHistory.ps1
6 2 Get-SSID.ps1
6 2 Invoke-DscPullAndApply.ps1
8 3 Move-Drive.ps1
7 2 New-ComputerList.ps1
6 2 New-Directory.ps1
6 3 Set-Proxy.ps1
7 2 Shortcut.ps1
6 3 Start-Delprof.ps1
6 3 Suspend-Computer.ps1
9 4 SystemInformation.ps1
6 3 Test-ModuleSpeed.ps1
7 5 Test-TCPConnection.ps1
6 2 Update-ModuleReadMe.ps1
11 3 Watch-Here.ps1

Test #2

dotsource(ms) scriptblock(ms) filename(test data)
40 24 Approve-Script.ps1
8 4 Clear-PrinterQueue.ps1
24 12 ConvertTo-ImageFormat.ps1
14 8 Copy-MultipleItems.ps1
7 4 Enter-RemoteSession.ps1
10 4 Get-CurrentUser.ps1
30 6 Get-LogonHistory.ps1
6 4 Get-SSID.ps1
7 4 Invoke-DscPullAndApply.ps1
11 8 Move-Drive.ps1
11 5 New-ComputerList.ps1
11 4 New-Directory.ps1
6 5 Set-Proxy.ps1
11 5 Shortcut.ps1
10 12 Start-Delprof.ps1
12 5 Suspend-Computer.ps1
69 5 SystemInformation.ps1
11 4 Test-ModuleSpeed.ps1
6 7 Test-TCPConnection.ps1
8 4 Update-ModuleReadMe.ps1
10 9 Watch-Here.ps1

This[1] blog post describes a faster method of importing use script into
the powershell session by loading the file contents into memory prior to
letting powershell parse them for auto-complete values.

Reference:

1: https://becomelotr.wordpress.com/2017/02/13/expensive-dot-sourcing/

Testing:

Test cmderdev#1
---
dotsource(ms) | scriptblock(ms) | filename(test data)
------|------|----
  18  |  13  | Approve-Script.ps1
   6  |   2  | Clear-PrinterQueue.ps1
  14  |   3  | ConvertTo-ImageFormat.ps1
   9  |   2  | Copy-MultipleItems.ps1
   6  |   2  | Enter-RemoteSession.ps1
   6  |   3  | Get-CurrentUser.ps1
   7  |   3  | Get-LogonHistory.ps1
   6  |   2  | Get-SSID.ps1
   6  |   2  | Invoke-DscPullAndApply.ps1
   8  |   3  | Move-Drive.ps1
   7  |   2  | New-ComputerList.ps1
   6  |   2  | New-Directory.ps1
   6  |   3  | Set-Proxy.ps1
   7  |   2  | Shortcut.ps1
   6  |   3  | Start-Delprof.ps1
   6  |   3  | Suspend-Computer.ps1
   9  |   4  | SystemInformation.ps1
   6  |   3  | Test-ModuleSpeed.ps1
   7  |   5  | Test-TCPConnection.ps1
   6  |   2  | Update-ModuleReadMe.ps1
  11  |   3  | Watch-Here.ps1

Test cmderdev#2
---
dotsource(ms) | scriptblock(ms) | filename(test data)
------|------|-----
  40  |  24  |  Approve-Script.ps1
   8  |   4  |  Clear-PrinterQueue.ps1
  24  |  12  |  ConvertTo-ImageFormat.ps1
  14  |   8  |  Copy-MultipleItems.ps1
   7  |   4  |  Enter-RemoteSession.ps1
  10  |   4  |  Get-CurrentUser.ps1
  30  |   6  |  Get-LogonHistory.ps1
   6  |   4  |  Get-SSID.ps1
   7  |   4  |  Invoke-DscPullAndApply.ps1
  11  |   8  |  Move-Drive.ps1
  11  |   5  |  New-ComputerList.ps1
  11  |   4  |  New-Directory.ps1
   6  |   5  |  Set-Proxy.ps1
  11  |   5  |  Shortcut.ps1
  10  |  12  |  Start-Delprof.ps1
  12  |   5  |  Suspend-Computer.ps1
  69  |   5  |  SystemInformation.ps1
  11  |   4  |  Test-ModuleSpeed.ps1
   6  |   7  |  Test-TCPConnection.ps1
   8  |   4  |  Update-ModuleReadMe.ps1
  10  |   9  |  Watch-Here.ps1
@Jaykul
Copy link

Jaykul commented Feb 15, 2017

Just remember; it's faster because it's bypassing execution policy.

@Jackbennett
Copy link
Contributor Author

That could possibly be a win, at the moment the whole console session is run with -ExecutionPolicy Bypass to get around the issue of loading our profile. Maybe we should use this trick for the profile as well and then cmder can leave the execution policy alone.

@stale
Copy link

stale bot commented May 25, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs. Thank you for your contribution.

@stale stale bot added the 👀 Awaiting Response Waiting to hear back from the issue reporter. label May 25, 2019
@stale
Copy link

stale bot commented Jun 1, 2019

This issue has been automatically closed due to it not having any activity since it was marked as stale. Thank you for your contribution.

@stale stale bot closed this Jun 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👀 Awaiting Response Waiting to hear back from the issue reporter. 🛠 Status: Requires Testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants