Skip to content

Instantly share code, notes, and snippets.

@IISResetMe
Created November 10, 2019 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IISResetMe/b87703ba062f6d742792fcd95d360014 to your computer and use it in GitHub Desktop.
Save IISResetMe/b87703ba062f6d742792fcd95d360014 to your computer and use it in GitHub Desktop.
# download and install https://github.com/IISResetMe/MeasureScript/tree/master/src
Import-Module MeasureScript
Measure-Script -ScriptBlock {# use a stopwatch to measure performance
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
# create a StringBuilder
$text = ""
# appending a string often
# using foreach and avoiding the pipeline
foreach($_ in (1..10000))
{
# replace operator += with AddLine():
$text += "working on $_`r`n"
}} |Tee-Object -Variable results
# Copy $results[11].TimeLine.TimeSpans to a file and feed to a line graph plotter (I just pasted it into Excel)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment