0

Set timing on statement tells us the amount of time consumed to process a query after each query in SQL-Plus. I need to know if there is a way to get the same time consumed output in C#? (A select command to get time consumed for last executed query from data dictionary or something like that)

  • There is nothing like that built in. You can use a `StopWatch` to time whatever it is that you want to time, however. – Glorin Oakenfoot Dec 01 '15 at 18:10
  • As mentioned above there is no such thing for this natively, but I suggest you to take a look at command pattern. Where you can create your commands and queries and decorate them with such audits as you wish. – kayess Dec 01 '15 at 18:13

1 Answers1

0

There is nothing built-in to any List or Collection types to get execution time, however you could do something like this:

DateTime start = DateTime.Now;

TimedCommandsToExecute();

TimeSpan cost = DateTime.Now.Subtract(start);

As pointed out below by @GlorinOakenfoot - the use of StopWatch is more accurate. Refer to this SO question/answer: Is DateTime.Now the best way to measure a function's performance?

Community
  • 1
  • 1
gmiley
  • 6,531
  • 1
  • 13
  • 25