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

custom-completions: scoop: improve performance of getting scoop commands #988

Merged
merged 1 commit into from
Dec 7, 2024

Conversation

e2dk4r
Copy link
Contributor

@e2dk4r e2dk4r commented Dec 7, 2024

Instead of calling scoop that calls powershell, use nushell's native commands.

On Windows 11 virtual machine,
powershell takes 330ms 492µs 860ns on fastest case,
with this commit takes 23ms 24µs 660ns on slowest.

> use old-scoop-completions.nu *
> let oldTimes = (1..10 | each { timeit { scoopCommands } })
> $oldTimes | sort --reverse
╭───┬───────────────────╮
│ 0 │ 357ms 565µs 720ns │
│ 1 │  344ms 64µs 450ns │
│ 2 │ 343ms 264µs 680ns │
│ 3 │  342ms 686µs 10ns │
│ 4 │ 342ms 241µs 740ns │
│ 5 │ 338ms 365µs 910ns │
│ 6 │ 337ms 682µs 790ns │
│ 7 │ 335ms 473µs 290ns │
│ 8 │ 335ms 186µs 830ns │
│ 9 │ 330ms 492µs 860ns │
╰───┴───────────────────╯
> $oldTimes | math avg
340ms 702µs 428ns

> use scoop-completions.nu *
> let newTimes = (1..10 | each { timeit { scoopCommands } })
> $newTimes | sort --reverse
╭───┬──────────────────╮
│ 0 │  23ms 24µs 660ns │
│ 1 │  18ms 33µs 480ns │
│ 2 │ 15ms 597µs 650ns │
│ 3 │ 15ms 412µs 850ns │
│ 4 │  15ms 58µs 770ns │
│ 5 │  14ms 536µs 30ns │
│ 6 │  14ms 366µs 20ns │
│ 7 │ 14ms 175µs 270ns │
│ 8 │ 13ms 688µs 730ns │
│ 9 │ 13ms 378µs 590ns │
╰───┴──────────────────╯
> $newTimes | math avg
15ms 727µs 205ns

Instead of calling scoop that calls powershell, use nushell's native
commands.

On Windows 11 virtual machine,
powershell takes '330ms 492µs 860ns' on fastest case,
with this commit takes '23ms 24µs 660ns' on slowest.

```nu
> use old-scoop-completions.nu *
> let oldTimes = (1..10 | each { timeit { scoopCommands } })
> $oldTimes | sort --reverse
╭───┬───────────────────╮
│ 0 │ 357ms 565µs 720ns │
│ 1 │  344ms 64µs 450ns │
│ 2 │ 343ms 264µs 680ns │
│ 3 │  342ms 686µs 10ns │
│ 4 │ 342ms 241µs 740ns │
│ 5 │ 338ms 365µs 910ns │
│ 6 │ 337ms 682µs 790ns │
│ 7 │ 335ms 473µs 290ns │
│ 8 │ 335ms 186µs 830ns │
│ 9 │ 330ms 492µs 860ns │
╰───┴───────────────────╯
> $oldTimes | math avg
340ms 702µs 428ns

> use scoop-completions.nu *
> let newTimes = (1..10 | each { timeit { scoopCommands } })
> $newTimes | sort --reverse
╭───┬──────────────────╮
│ 0 │  23ms 24µs 660ns │
│ 1 │  18ms 33µs 480ns │
│ 2 │ 15ms 597µs 650ns │
│ 3 │ 15ms 412µs 850ns │
│ 4 │  15ms 58µs 770ns │
│ 5 │  14ms 536µs 30ns │
│ 6 │  14ms 366µs 20ns │
│ 7 │ 14ms 175µs 270ns │
│ 8 │ 13ms 688µs 730ns │
│ 9 │ 13ms 378µs 590ns │
╰───┴──────────────────╯
> $newTimes | math avg
15ms 727µs 205ns
```
@fdncred fdncred merged commit 6bd54bf into nushell:main Dec 7, 2024
1 check passed
@fdncred
Copy link
Collaborator

fdncred commented Dec 7, 2024

Thanks

NotTheDr01ds pushed a commit to NotTheDr01ds/nu_scripts-fork that referenced this pull request Dec 20, 2024
…nds (nushell#988)

Instead of calling scoop that calls powershell, use nushell's native
commands.

On Windows 11 virtual machine,
powershell takes `330ms 492µs 860ns` on **fastest** case,
with this commit takes `23ms 24µs 660ns` on **slowest**.

```nu
> use old-scoop-completions.nu *
> let oldTimes = (1..10 | each { timeit { scoopCommands } })
> $oldTimes | sort --reverse
╭───┬───────────────────╮
│ 0 │ 357ms 565µs 720ns │
│ 1 │  344ms 64µs 450ns │
│ 2 │ 343ms 264µs 680ns │
│ 3 │  342ms 686µs 10ns │
│ 4 │ 342ms 241µs 740ns │
│ 5 │ 338ms 365µs 910ns │
│ 6 │ 337ms 682µs 790ns │
│ 7 │ 335ms 473µs 290ns │
│ 8 │ 335ms 186µs 830ns │
│ 9 │ 330ms 492µs 860ns │
╰───┴───────────────────╯
> $oldTimes | math avg
340ms 702µs 428ns

> use scoop-completions.nu *
> let newTimes = (1..10 | each { timeit { scoopCommands } })
> $newTimes | sort --reverse
╭───┬──────────────────╮
│ 0 │  23ms 24µs 660ns │
│ 1 │  18ms 33µs 480ns │
│ 2 │ 15ms 597µs 650ns │
│ 3 │ 15ms 412µs 850ns │
│ 4 │  15ms 58µs 770ns │
│ 5 │  14ms 536µs 30ns │
│ 6 │  14ms 366µs 20ns │
│ 7 │ 14ms 175µs 270ns │
│ 8 │ 13ms 688µs 730ns │
│ 9 │ 13ms 378µs 590ns │
╰───┴──────────────────╯
> $newTimes | math avg
15ms 727µs 205ns
```
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