Skip to content

Instantly share code, notes, and snippets.

@KevinMarquette
Last active November 10, 2016 01:39
Show Gist options
  • Save KevinMarquette/3bb280ddbd8ee0c0b56e7f74f1897de6 to your computer and use it in GitHub Desktop.
Save KevinMarquette/3bb280ddbd8ee0c0b56e7f74f1897de6 to your computer and use it in GitHub Desktop.
function Get-Double ($number){$number + $number}
function Get-Double2
{
<#
.SYNOPSIS
.EXAMPLE
New-Function -ComputerName server
.EXAMPLE
.NOTES
#>
[cmdletbinding()]
param(
# Pipeline variable
[Parameter(
Mandatory = $true,
HelpMessage = ' ',
Position = 0,
ValueFromPipeline = $true
)]
[Alias('value')]
[int[]]$Number
)
process
{
foreach($node in $Number)
{
$node + $node
}
}
}
$max = 100000
Measure-Command {
0..$max | %{$_ + $_}
} | FT t*seconds
Measure-Command {
$list = 0..$max
foreach($item in $list)
{
$item + $item
}
} | FT t*seconds
Measure-Command {
(0..$max).ForEach({
$_+ $_
})
} | FT t*seconds
Measure-Command {
0..$max | %{ Get-Double $_}
} | FT t*seconds
Measure-Command {
0..$max | %{ Get-Double2 $_}
} | FT t*seconds
Measure-Command {
0..$max | Get-Double2
} | FT t*seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment