Update the measure-*.ps1 scripts

This commit is contained in:
Markus Fleschutz 2023-09-13 07:57:23 +02:00
parent 15f0a279b9
commit 3347acc028
9 changed files with 25 additions and 17 deletions

View File

@ -11,7 +11,7 @@
Specifies the number of integers to sort
.EXAMPLE
PS> ./measure-BubbleSort.ps1
🧭 Sorting of 1000 integers by BubbleSort took 0.7291663 sec
🧭 0.729 sec to sort 1000 integers by BubbleSort
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -40,5 +40,6 @@ $list = (1..$NumIntegers | foreach{Get-Random -minimum 1 -maximum $numIntegers})
$stopWatch = [system.diagnostics.stopwatch]::startNew()
[BubbleSort]::Sort($list)
[float]$elapsed = $stopWatch.Elapsed.TotalSeconds
"🧭 Sorting of $numIntegers integers by BubbleSort took $elapsed sec"
$elapsed3 = "{0:N3}" -f $elapsed # formatted to 3 decimal places
"🧭 $elapsed3 sec to sort $numIntegers integers by BubbleSort"
exit 0 # success

View File

@ -16,7 +16,7 @@
Specifies the number of integers to sort
.EXAMPLE
PS> ./measure-BucketSort.ps1
🧭 Sorting of 1000 integers by BucketSort took 0.0653755 sec
🧭 0.065 sec to sort 1000 integers by BucketSort
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -63,5 +63,6 @@ $list = (1..$numIntegers | foreach{Get-Random -minimum 1 -maximum $numIntegers})
$stopWatch = [system.diagnostics.stopwatch]::startNew()
[BucketSort]::Sort($list)
[float]$elapsed = $stopWatch.Elapsed.TotalSeconds
"🧭 Sorting of $numIntegers integers by BucketSort took $elapsed sec"
$elapsed3 = "{0:N3}" -f $elapsed # formatted to 3 decimal places
"🧭 $elapsed3 sec to sort $numIntegers integers by BucketSort"
exit 0 # success

View File

@ -16,7 +16,7 @@
Specifies the number of integers to sort
.EXAMPLE
PS> ./measure-CountingSort.ps1
🧭 Sorting of 1000 integers by CountingSort took 0.0454597 sec
🧭 0.045 sec to sort 1000 integers by CountingSort
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -54,5 +54,6 @@ $list = (1..$numIntegers | foreach{Get-Random -minimum 1 -maximum $numIntegers})
$stopWatch = [system.diagnostics.stopwatch]::startNew()
[CountingSort]::Sort($list)
[float]$elapsed = $stopWatch.Elapsed.TotalSeconds
"🧭 Sorting of $numIntegers integers by CountingSort took $elapsed sec"
$elapsed3 = "{0:N3}" -f $elapsed # formatted to 3 decimal places
"🧭 $elapsed3 sec to sort $numIntegers integers by CountingSort"
exit 0 # success

View File

@ -14,7 +14,7 @@
Specifies the number of integers to sort
.EXAMPLE
PS> ./measure-HeapSort.ps1
🧭 Sorting of 1000 integers by HeapSort took 0.6145732 sec
🧭 0.614 sec to sort 1000 integers by HeapSort
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -71,5 +71,6 @@ $list = (1..$numIntegers | foreach{Get-Random -minimum 1 -maximum $numIntegers})
$stopWatch = [system.diagnostics.stopwatch]::startNew()
[HeapSort]::Sort($list)
[float]$elapsed = $stopWatch.Elapsed.TotalSeconds
"🧭 Sorting of $numIntegers integers by HeapSort took $elapsed sec"
$elapsed3 = "{0:N3}" -f $elapsed # formatted to 3 decimal places
"🧭 $elapsed3 sec to sort $numIntegers integers by HeapSort"
exit 0 # success

View File

@ -10,7 +10,7 @@
Specifies the number of integers to sort
.EXAMPLE
PS> ./measure-InsertionSort.ps1
🧭 Sorting of 1000 integers by InsertionSort took 0.4234268 sec
🧭 0.423 sec to sort 1000 integers by InsertionSort
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -44,5 +44,6 @@ $list = (1..$numIntegers | foreach{Get-Random -minimum 1 -maximum $numIntegers})
$stopWatch = [system.diagnostics.stopwatch]::startNew()
[InsertionSort]::Sort($list)
[float]$elapsed = $stopWatch.Elapsed.TotalSeconds
"🧭 Sorting of $numIntegers integers by InsertionSort took $elapsed sec"
$elapsed3 = "{0:N3}" -f $elapsed # formatted to 3 decimal places
"🧭 $elapsed3 sec to sort $numIntegers integers by InsertionSort"
exit 0 # success

View File

@ -12,7 +12,7 @@
Specifies the number of integers to sort
.EXAMPLE
PS> ./measure-MergeSort.ps1
🧭 Sorting of 1000 integers by MergeSort took 0.3786619 sec
🧭 0.378 sec to sorting 1000 integers by MergeSort
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -67,5 +67,6 @@ $list = (1..$numIntegers | foreach{Get-Random -minimum 1 -maximum $numIntegers})
$stopWatch = [system.diagnostics.stopwatch]::startNew()
[MergeSort]::Sort($list)
[float]$elapsed = $stopWatch.Elapsed.TotalSeconds
"🧭 Sorting of $numIntegers integers by MergeSort took $elapsed sec"
$elapsed3 = "{0:N3}" -f $elapsed # formatted to 3 decimal places
"🧭 $elapsed3 sec to sort $numIntegers integers by MergeSort"
exit 0 # success

View File

@ -11,7 +11,7 @@
Specifies the number of integers to sort
.EXAMPLE
PS> ./measure-QuickSort.ps1
🧭 Sorting of 1000 integers by QuickSort took 0.0853411 sec
🧭 0.085 sec to sort 1000 integers by QuickSort
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -49,5 +49,6 @@ $list = (1..$numIntegers | foreach{Get-Random -minimum 1 -maximum $numIntegers})
$stopWatch = [system.diagnostics.stopwatch]::startNew()
[QuickSort]::Sort($list, 0, $list.Count-1)
[float]$elapsed = $stopWatch.Elapsed.TotalSeconds
"🧭 Sorting of $numIntegers integers by QuickSort took $elapsed sec"
$elapsed3 = "{0:N3}" -f $elapsed # formatted to 3 decimal places
"🧭 $elapsed3 sec to sort $numIntegers integers by QuickSort"
exit 0 # success

View File

@ -12,7 +12,7 @@
Specifies the number of integers to sort
.EXAMPLE
PS> ./measure-SelectionSort.ps1
🧭 Sorting of 1000 integers by SelectionSort took 0.3351773 sec
🧭 0.335 sec to sort 1000 integers by SelectionSort
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -41,5 +41,6 @@ $list = (1..$numIntegers | foreach{Get-Random -minimum 1 -maximum $numIntegers})
$stopWatch = [system.diagnostics.stopwatch]::startNew()
[SelectionSort]::Sort($list)
[float]$elapsed = $stopWatch.Elapsed.TotalSeconds
"🧭 Sorting of $numIntegers integers by SelectionSort took $elapsed sec"
$elapsed3 = "{0:N3}" -f $elapsed # formatted to 3 decimal places
"🧭 $elapsed3 sec to sort $numIntegers integers by SelectionSort"
exit 0 # success

View File

@ -7,7 +7,7 @@
Specifies the number of integers to sort (3000 by default)
.EXAMPLE
PS> ./measure-sorting-algorithms.ps1
🧭 Sorting of 3000 integers by BubbleSort took 6.041561 sec
🧭 6.041 sec to sort 3000 integers by BubbleSort
...
.LINK
https://github.com/fleschutz/PowerShell