This content originally appeared on DEV Community and was authored by DEV Community
As I was nearing completion of implementing Ray Tracing in One Weekend in Go, I felt the need to measure the time it would take to render a scene.
My day-to-day work is in CentOS, so I was tempted to try time gortiw
in Windows Terminal, as it already had some improvements over cmd
, like ssh
and an alias for ls
. I was disappointed. There was no easily accessible time
-like command nor an alias.
After searching a little, I got to a solution: using PowerShell's Measure-Command
. Then I just needed to create a function time in my PowerShell profile and it was done.
Steps
- Edit your
Documents\PowerShell\Microsoft.PowerShell_profile.ps1
-
Add the line
function time { $Command = "$args"; Measure-Command { Invoke-Expression $Command 2>&1 | out-default} }
Open a new instance or tab of PowerShell to use the new time function. Ex:
time gortiw.exe
Satisfied with the results, the next step will be using a profiler to check where to improve.
This content originally appeared on DEV Community and was authored by DEV Community
DEV Community | Sciencx (2022-03-05T00:32:33+00:00) Measuring program execution time in PowerShell. Retrieved from https://www.scien.cx/2022/03/05/measuring-program-execution-time-in-powershell/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.