Skip to content

Commit aa5fa61

Browse files
Switch to approved verbs (2/2)
1 parent 3d58ae5 commit aa5fa61

File tree

4 files changed

+25
-27
lines changed

4 files changed

+25
-27
lines changed

PSOneTools/2.4/Invoke-PSOneForeach.ps1

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
function Foreach-ObjectFast
1+
function Invoke-PSOneForeach
22
{
33
<#
44
.SYNOPSIS
5-
Faster Foreach-Object
5+
Faster ForEach-Object
66
77
.DESCRIPTION
8-
Foreach-ObjectFast can replace the built-in Foreach-Object and improves pipeline speed considerably.
9-
Foreach-ObjectFast supports only the most commonly used parameters -Begin, -Process, and -End, so you can replace
8+
Invoke-PSOneForeach can replace the built-in ForEach-Object and improves pipeline speed considerably.
9+
Invoke-PSOneForeach supports only the most commonly used parameters -Begin, -Process, and -End, so you can replace
1010
11-
1..100 | Foreach-Object { 'Server{0:d3}' -f $_ }
11+
1..100 | ForEach-Object { 'Server{0:d3}' -f $_ }
1212
1313
with
1414
15-
1..100 | Foreach-ObjectFast { 'Server{0:d3}' -f $_ }
15+
1..100 | Invoke-PSOneForeach { 'Server{0:d3}' -f $_ }
1616
17-
but you cannot currently replace instances of Foreach-Object that uses the less commonly used parameters,
17+
but you cannot currently replace instances of ForEach-Object that uses the less commonly used parameters,
1818
like -RemainingScripts, -MemberNames, and -ArgumentList
1919
20-
Foreach-ObjectFast has a performance benefit per iteration, so the more objects
20+
Invoke-PSOneForeach has a performance benefit per iteration, so the more objects
2121
you send through the pipeline, the more significant performace benefits you will see.
2222
23-
Foreach-ObjectFast is using a steppable pipeline internally which performs better.
23+
Invoke-PSOneForeach is using a steppable pipeline internally which performs better.
2424
However because of this, the debugging experience will be different, and internal
2525
variables such as $MyInvocation may yield different results. For most every-day tasks,
2626
these changes are not important.
2727
28-
A complete explanation of what Where-ObjectFast does can be found here:
28+
A complete explanation of what Invoke-PSOneWhere does can be found here:
2929
https://powershell.one/tricks/performance/pipeline
3030
3131
.EXAMPLE
3232
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
3333
34-
$result = 1..1000000 | Foreach-ObjectFast -Process {
34+
$result = 1..1000000 | Invoke-PSOneForeach -Process {
3535
"I am at $_"
3636
}
3737
3838
$report = '{0} elements in {1:n2} seconds'
3939
$report -f $result.Count, $stopwatch.Elapsed.TotalSeconds
4040
4141
Demos the speed improvements. Run this script to see how well it performs,
42-
then replace Foreach-ObjectFast with the default Foreach-Object, and check out
42+
then replace Invoke-PSOneForeach with the default ForEach-Object, and check out
4343
the performace difference. $result is the same in both cases.
4444
4545
.LINK
4646
https://powershell.one/tricks/performance/pipeline
47-
https://github.com/TobiasPSP/Modules.PSOneTools/blob/master/PSOneTools/1.2/Foreach-ObjectFast.ps1
47+
https://github.com/TobiasPSP/Modules.PSOneTools/blob/master/PSOneTools/1.2/Invoke-PSOneForeach.ps1
4848
#>
4949

5050
param

PSOneTools/2.4/Invoke-PSOneGroup.ps1

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
2-
3-
function Group-ObjectFast
1+
function Invoke-PSOneGroup
42
{
53
[CmdletBinding(DefaultParameterSetName='Analysis')]
64
param

PSOneTools/2.4/Invoke-PSOneWhere.ps1

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
function Where-ObjectFast
1+
function Invoke-PSOneWhere
22
{
33
<#
44
.SYNOPSIS
55
Faster Where-Object
66
77
.DESCRIPTION
8-
Where-ObjectFast can replace the built-in Where-Object and improves pipeline speed considerably.
9-
Where-ObjectFast supports only the scriptblock version of Where-Object, so you can replace
8+
Invoke-PSOneWhere can replace the built-in Where-Object and improves pipeline speed considerably.
9+
Invoke-PSOneWhere supports only the scriptblock version of Where-Object, so you can replace
1010
1111
Get-Service | Where-Object { $_.Status -eq 'Running' }
1212
1313
with
1414
15-
Get-Service | Where-ObjectFast { $_.Status -eq 'Running' }
15+
Get-Service | Invoke-PSOneWhere { $_.Status -eq 'Running' }
1616
1717
but you cannot currently replace the short form of Where-Object:
1818
1919
Get-Service | Where-Object Status -eq Running
2020
21-
Where-ObjectFast has a performance benefit per iteration, so the more objects
21+
Invoke-PSOneWhere has a performance benefit per iteration, so the more objects
2222
you send through the pipeline, the more significant performace benefits you will see.
2323
24-
Where-ObjectFast is using a steppable pipeline internally which performs better.
24+
Invoke-PSOneWhere is using a steppable pipeline internally which performs better.
2525
However because of this, the debugging experience will be different, and internal
2626
variables such as $MyInvocation may yield different results. For most every-day tasks,
2727
these changes are not important.
2828
29-
A complete explanation of what Where-ObjectFast does can be found here:
29+
A complete explanation of what Invoke-PSOneWhere does can be found here:
3030
https://powershell.one/tricks/performance/pipeline
3131
3232
.EXAMPLE
3333
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
3434
35-
$result = 1..1000000 | Where-ObjectFast -FilterScript {
35+
$result = 1..1000000 | Invoke-PSOneWhere -FilterScript {
3636
$_ % 5
3737
}
3838
3939
$report = '{0} elements in {1:n2} seconds'
4040
$report -f $result.Count, $stopwatch.Elapsed.TotalSeconds
4141
4242
Demos the speed improvements. Run this script to see how well it performs,
43-
then replace Where-ObjectFast with the default Where-Object, and check out
43+
then replace Invoke-PSOneWhere with the default Where-Object, and check out
4444
the performace difference. $result is the same in both cases.
4545
4646
.LINK
4747
https://powershell.one/tricks/performance/pipeline
48-
https://github.com/TobiasPSP/Modules.PSOneTools/blob/master/PSOneTools/1.2/Where-ObjectFast.ps1
48+
https://github.com/TobiasPSP/Modules.PSOneTools/blob/master/PSOneTools/1.2/Invoke-PSOneWhere.ps1
4949
#>
5050

5151

PSOneTools/2.4/PSOneTools.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Description = 'commands taken from articles published at https://powershell.one'
2020
# TypesToProcess = @()
2121
# FormatsToProcess = @()
2222
# NestedModules = @()
23-
FunctionsToExport = @('Assert-PsOneFolderExists','Start-PSOneClipboardListener','Stop-PSOneClipboardListener','Get-PSOneClipboardListenerStatus','Show-PSOneApplicationWindow','Find-PSOneDuplicateFile','Test-PSOnePort','Test-PSOnePing','Foreach-ObjectFast','Where-ObjectFast','Test-PSOneScript','Get-PSOneToken','Expand-PSOneToken','Get-PSOneDirectory','Group-ObjectFast','Find-PSOneDuplicateFileFast','Get-PsOneFileHash')
23+
FunctionsToExport = @('Assert-PsOneFolderExists','Start-PSOneClipboardListener','Stop-PSOneClipboardListener','Get-PSOneClipboardListenerStatus','Show-PSOneApplicationWindow','Find-PSOneDuplicateFile','Test-PSOnePort','Test-PSOnePing','Invoke-PSOneForeach','Invoke-PSOneWhere','Test-PSOneScript','Get-PSOneToken','Expand-PSOneToken','Get-PSOneDirectory','Invoke-PSOneGroup','Find-PSOneDuplicateFileFast','Get-PsOneFileHash')
2424
#CmdletsToExport = '*'
2525
#VariablesToExport = '*'
2626
#AliasesToExport = '*'

0 commit comments

Comments
 (0)