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

Optimize ps_pkgs #163

Merged
merged 8 commits into from
Jan 31, 2023
Merged

Optimize ps_pkgs #163

merged 8 commits into from
Jan 31, 2023

Conversation

Carterpersall
Copy link
Contributor

@Carterpersall Carterpersall commented Oct 17, 2022

  • Replicates the functionality of Get-InstalledModule and Get-InstalledScript, which apply some filters to Get-Package
    • Has a slight speed increase with Modules, and a slight speed decrease with Scripts
      • I suspect it has something to do with the quantity of modules or scripts that are found, as for me no scripts are installed and some modules are
    • Largest speed increase comes from the reuse of Get-Package's output

Speed (Will populate later):

  • PowerShell 5:
  • PowerShell 7:

Bottlenecked Speed:

  • PowerShell 5:
    • 3962ms → 3771ms
      • 5.06% Faster
  • PowerShell 7:
    • 5800ms → 5289ms
      • 9.66% Faster

- Replicates the functionality of `Get-InstalledModule` and `Get-InstalledScript`
 - Has a slight speed increase with Modules, and a slight speed decrease with Scripts
  - Largest speed increase comes from the reuse of the output of Get-Package
Removed unneeded if-statement and replaced the pipe
- Merged the foreach loops into one, saving a few milliseconds

- Also a extension I have in VSCode cut a bunch of trailing whitespace from $localeLookup
- Completely redid the processing of `Get-Package` output
  - Instead of using 2 foreach loops, uses a Where statement and counts the returned values
- 3 - 8x faster on the processing step
@Carterpersall Carterpersall mentioned this pull request Nov 3, 2022
16 tasks
@rashil2000
Copy link
Member

On my system, on both PS 5.1 and 7.3.1, this returns the count of both modules and scripts as 0 😕

Also, can you please make the formatting changes in a separate PR?

- Used `-contains`, which doesn't take wildcards
  - Replaced with `-like`
@Carterpersall
Copy link
Contributor Author

On my system, on both PS 5.1 and 7.3.1, this returns the count of both modules and scripts as 0 😕

For some reason, I used -contains instead on -like, which meant that my wildcards weren't working. Should be fixed now

Also, can you please make the formatting changes in a separate PR?

Yeah, I can. When I committed that, I couldn't figure out where the setting was that was making VSCode was automatically trim whitespace. For now, I've reverted the change.

@rashil2000 rashil2000 merged commit 625a5c8 into lptstr:master Jan 31, 2023
@Carterpersall Carterpersall deleted the Optimive-ps_pkgs branch January 31, 2023 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants