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)
Asked
Active
Viewed 115 times
0
-
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 Answers
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?
-
4Note that although this is *valid*, `StopWatch` is the preferred method as it may be more precise. See http://stackoverflow.com/a/28648/4372746 – Glorin Oakenfoot Dec 01 '15 at 18:19
-