How to measure the running time of a C # console application?

I need to activate an application that runs less than 1 second, but I can’t find out how to determine the runtime.

+4
source share
4 answers

Configure Stopwatch during initialization and check its Elapsed output.

+6
source

How about using a stopwatch class.

http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx

In particular, pay attention to the note displayed on MSDN

On a multiprocessor computer, it does not matter which processor the thread runs on. However, due to errors in the BIOS or hardware abstraction (HAL), you may get different synchronization results on different processors. To indicate the affinity of a processor for a thread, use the ProcessThread.ProcessorAffinity method.

+2
source

You can also get the time at the beginning and at the end of the program and subtract it

http://msdn.microsoft.com/en-us/library/system.datetime.now.aspx

0
source

console application does not close if you write
Console.ReadLine ();

0
source

Source: https://habr.com/ru/post/1346999/


All Articles