'How to get a process startup time in powershell?
Is there a way to get the process startup time : not start time, not execution time, but the time it takes to load a program/binary in memory ?
Solution 1:[1]
Take a look at the answer to this other question: How can I use a Windows batch file to measure the performance of console application?
The 3 command:
for /L %%n in (1,1, 1000) do <nul set /p "="
Is being measured. Try replacing this "for" command with your executable program.
Solution 2:[2]
In the context of PowerShell, "load a program/binary in memory" is very unclear. Are you wanting the amount of time from when the ps1 script starts to the time it is fully loaded, along with all the modules, DLLs, etc...?
If this is what you want, then you probably need another ps1 script to get a timestamp before jumpstarting your primary ps1 script. You could do something like like the following.
StartTimeCaller.ps1:
$StartTime = [DateTime]::Now
& "$PSScriptRoot\ActualProgram.ps1"
With this code in your ActualProgram.ps1:
$TimeDifference = [DateTime]::Now - $StartTime
$TimeDifference
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Darin |
| Solution 2 | Darin |
