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 dot source #1255

Closed
wants to merge 57 commits into from
Closed

Conversation

Jackbennett
Copy link
Contributor

So this is a PR because I'd like to see some testing and hopefully some benchmarks regarding the speed increase. I've found it a bit random if it is faster or not.

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

MartiUK and others added 30 commits March 20, 2016 12:23
Join-Path won't add "\"'s without the use of a delimeter.  In this case there is no delimiter and as a result the script will fail when it tries to look up $CmderModulePath.
Fix missing "\" when building dirpath to psmodules
clink.get_cwd() is returning a string which is differently encoded than what
clink.prompt.value expects. This results in garbled path names if the path
condains non-ASCII chars. The (arguable hacky) solution is to parse the old
prompt for the current directory (which breaks if the user sets a PROMPT env var
which is incompatible to the regex used here...).

Also parse out a environment name set by systems like virtualenv or conda: this
could be done more specifically by targeting each such system and using the
usually set environment variable but this would mean that we would have to do
that for each and every such system out there and that is probably not a sane
idea...
Parse the original prompt for cwd and env names
E.g., if ${CMDER_ROOT} is /c/Users/Foo Bar/cmder,
the following errors will occur:
  bash: pushd: /c/Users/Foo: No such file or directory
  bash: [: /c/Users/Foo: binary operator expected
  bash: /c/Users/Foo: No such file or directory
Inspecting the script uncovers similar problems elsewhere
not encountered in my initial testing. They are fixed accordingly.
…der_root_has_spaces

Fix bash login when $CMDER_ROOT has spaces
just minor typos
After execution command: git add * git continues to operate without closing. The process does not stop.
Stanzilla and others added 26 commits October 5, 2016 02:16
Fixes cmderdev#1122 by simply calling CreateProcess before the SendMessageTimeout
calls that are used to propagate environment variable changes.
Fix for slow startup under certain conditions (cmderdev#1122)
Documented some undocumented tab related shorcuts
Fix cmderdev#1245: Allow alias value to contain '=' characters
This[1] blog post describes a faster method of importing use script into
the powershell session by loading the file contents into memory proir 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
@Jackbennett
Copy link
Contributor Author

I see what's happened here, my branch was created from the latest in master not development.

@Jackbennett Jackbennett deleted the faster-dotSource branch February 15, 2017 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.