Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 76 additions & 7 deletions tests/perf-1.1.6.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,80 @@
$func = 'https://gist.githubusercontent.com/santisq/bd3d1d47c89f030be1b4e57b92baaddd/raw/aa78870a9674e9e4769b05e333586bf405c1362c/Measure-Expression.ps1'
Invoke-RestMethod $func | Invoke-Expression
function Measure-Expression {
[CmdletBinding()]
[Alias('measureme', 'time')]
param(
[Parameter(Mandatory, Position = 0)]
[hashtable] $Tests,

[Parameter()]
[int32] $TestCount = 5,

[Parameter()]
[switch] $OutputAllTests,

[Parameter()]
[hashtable] $Parameters
)

end {
$allTests = 1..$TestCount | ForEach-Object {
foreach ($test in $Tests.GetEnumerator()) {
$sb = if ($Parameters) {
{ & $test.Value @Parameters }
}
else {
{ & $test.Value }
}

$now = [datetime]::Now
$null = $sb.Invoke()
$span = [datetime]::Now - $now

[pscustomobject]@{
TestRun = $_
Test = $test.Key
TimeSpan = $span
}

[GC]::Collect()
[GC]::WaitForPendingFinalizers()
}
} | Sort-Object TotalMilliseconds

$average = $allTests | Group-Object Test | ForEach-Object {
$avg = [Linq.Enumerable]::Average([long[]] $_.Group.TimeSpan.Ticks)

[pscustomobject]@{
Test = $_.Name
Average = $avg
}
} | Sort-Object Average

$average | Select-Object @(
'Test'
@{
Name = "Average ($TestCount invocations)"
Expression = { [timespan]::new($_.Average).ToString('hh\:mm\:ss\.fff') }
}
@{
Name = 'RelativeSpeed'
Expression = {
$relativespeed = $_.Average / $average[0].Average
[math]::Round($relativespeed, 2).ToString() + 'x'
}
}
)

if ($OutputAllTests.IsPresent) {
$allTests
}
}
}

$modulePath = Convert-Path $PSScriptRoot\..\output\PSADTree

Measure-Expression @{
'v1.1.6-pwsh-7' = { pwsh -File $PSScriptRoot\perfCode.ps1 $modulePath }
'v1.1.6-pwsh-5.1' = { powershell -File $PSScriptRoot\perfCode.ps1 $modulePath }
'v1.1.5-pwsh-7' = { pwsh -File $PSScriptRoot\perfCode.ps1 PSADTree }
'v1.1.5-pwsh-5.1' = { powershell -File $PSScriptRoot\perfCode.ps1 PSADTree }
Measure-Expression -TestCount 5 @{
'PSADTree v1.1.6-pwsh-7' = { pwsh -File $PSScriptRoot\perfCode.ps1 $modulePath }
'PSADTree v1.1.6-pwsh-5.1' = { powershell -File $PSScriptRoot\perfCode.ps1 $modulePath }
'PSADTree v1.1.5-pwsh-7' = { pwsh -File $PSScriptRoot\perfCode.ps1 PSADTree }
'PSADTree v1.1.5-pwsh-5.1' = { powershell -File $PSScriptRoot\perfCode.ps1 PSADTree }
}
7 changes: 3 additions & 4 deletions tests/perfCode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Import-Module $pathOrName
Write-Host "Running PSADTree v$((Get-Module PSADTree).Version)"

$objects = Get-ADObject -LDAPFilter '(|(objectClass=group)(objectClass=user))'
0..3 | ForEach-Object {
$objects | Where-Object ObjectClass -EQ group | Get-ADTreeGroupMember -Recursive -ShowAll
$objects | Get-ADTreePrincipalGroupMembership -Recursive -ShowAll
}
$objects = 0..15 | ForEach-Object { $objects }
$objects | Where-Object ObjectClass -EQ group | Get-ADTreeGroupMember -Recursive -ShowAll
$objects | Get-ADTreePrincipalGroupMembership -Recursive -ShowAll
Loading