1

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 ?

Segfault
  • 65
  • 7
  • Umm, how about kicking off a timer the moment you run the program, and then subtracting the start time from it? – Abraham Zinala Feb 02 '22 at 12:43
  • Elegant solution, i could do it, i was just wondering if there wasn't an already built-in cmdlet for this purpose. – Segfault Feb 02 '22 at 12:49
  • 2
    There's [Measure-Command](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/measure-command?view=powershell-7.2) to track script block execution time. Would that do? – vonPryz Feb 02 '22 at 13:20

2 Answers2

0

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.

Darin
  • 1,423
  • 1
  • 10
  • 12
0

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
Darin
  • 1,423
  • 1
  • 10
  • 12