Skip to content

Commit 670a534

Browse files
authored
Update Performance.md
- Add space between 'foreach' and the following parenthesis. - Change the faulty 'a la' to the correct 'à la'. - Write '.NET' and '.NET Framework' consistently the same throughout.
1 parent d82198f commit 670a534

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Best-Practices/Performance.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ If you're aware of multiple techniques to accomplish something, and you're writi
77
For example:
88

99
```PowerShell
10-
foreach($result in Do-Something) { $result.PropertyOne + $result.PropertyTwo }
10+
foreach ($result in Do-Something) { $result.PropertyOne + $result.PropertyTwo }
1111
Do-Something | ForEach-Object { $_.PropertyOne + $_.PropertyTwo }
1212
```
1313

@@ -40,7 +40,7 @@ ForEach-Object -Process {
4040
}
4141
```
4242

43-
As described elsewhere in this guide, many folks in the community would dislike this approach for aesthetic reasons. However, this approach has the advantage of utilizing PowerShell's pipeline to "stream" the content in file.txt. Provided that the fictional "Do-Something" command isn't blocking the pipeline (a la Sort-Object), the shell can send lines of content (String objects, technically) through the pipeline in a continuous stream, rather than having to buffer them all into memory.
43+
As described elsewhere in this guide, many folks in the community would dislike this approach for aesthetic reasons. However, this approach has the advantage of utilizing PowerShell's pipeline to "stream" the content in file.txt. Provided that the fictional "Do-Something" command isn't blocking the pipeline (à la Sort-Object), the shell can send lines of content (String objects, technically) through the pipeline in a continuous stream, rather than having to buffer them all into memory.
4444

4545
Some would argue that this second approach is always a poor one, and that if performance is an issue then you should devolve from a PowerShell-native approach into a lower-level .NET Framework approach:
4646

@@ -73,8 +73,8 @@ The moral here is that both aesthetic and performance are important consideratio
7373

7474
This is just a rough guideline, but as a general rule:
7575

76-
1. Language features are faster than features of the .net framework
77-
2. Compiled methods on objects and .net classes are still faster than script
76+
1. Language features are faster than features of the .NET Framework
77+
2. Compiled methods on objects and .NET classes are still faster than script
7878
3. Simple PowerShell script is still faster than calling functions or cmdlets
7979

8080
It's counter-intuitive that script is faster than calling cmdlets that are compiled, but it's frequently true, unless there is a lot of work being done by each cmdlet. The overhead of calling cmdlets and passing data around is significant. Of course, this is just a guideline, and you should always **measure**.

0 commit comments

Comments
 (0)