Time Windows applications launching (via Powershell?)

0

1

I am supporting a piece of software in our organization that has an effect on the performance of applications, most notably the opening of applications (it's data loss prevention software that injects itself into processes to watch for data leaving the organization).

I was wanting to do benchmarks of applications opening in milliseconds with, and without the software in place, ideally some sort of automated process to launch the application, and time it starting up. Is there any way to do this precisely, such with Powershell?

Ranger

Posted 2017-04-18T14:19:27.753

Reputation: 623

If you need precision, you should look into WPA. For ease of use, I would recommend procmon. Somewhere inbetween, you could use sysmon and filter on process create/terminated rules. – Lieven Keersmaekers – 2017-04-18T14:38:11.363

Answers

1

You can use the Process Class (System.Diagnostics) in .NET to measure the execution time of a piece of code.

The following code sample uses this class to measure a PowerShell command.

PowerShell benchmarking function. Or, the Windows equivalent of Unix's time command. - GitHub

Steven

Posted 2017-04-18T14:19:27.753

Reputation: 24 804

0

You should try Measure-Command. Iit provides stas back that look like this:

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 81
Ticks             : 815066
TotalDays         : 9.43363425925926E-07
TotalHours        : 2.26407222222222E-05
TotalMinutes      : 0.00135844333333333
TotalSeconds      : 0.0815066
TotalMilliseconds : 81.5066

Syntax look like Measure-command {dir c:\ /s}

uSlackr

Posted 2017-04-18T14:19:27.753

Reputation: 8 755

I tested it with "Measure-Command {Invoke-Item C:\Windows\System32\calc.exe }" and "Measure-Command" returned before calc.exe was even (visually) open. This doesn't seem to actually measure the process startup. – Ranger – 2017-04-18T16:03:28.330

@NexTerren - Invoke-Item doesn't wait, you should have used Start-Process -Wait instead. Ultimately, even that way you'll monitor to much. Read my comment, Powershell is not the right tool for this job (it can help automate the suggestions in comments but it can not monitor process startup) – Lieven Keersmaekers – 2017-04-19T04:38:53.993