Get execution timings

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
Partizan
Posts: 36
Joined: Fri 13 Nov 2009 10:18

Get execution timings

Post by Partizan » Wed 17 Dec 2014 14:19

Hi Devart,

We're trying to measure some metrics on our code.
Is there any way to get the time spent between sending query out and data fetched on the client? We tried to use OracleMonitor class, but looks like After Execute event it doesn't include the fetching time. Please advice.

Thank you.

Pinturiccio
Devart Team
Posts: 2125
Joined: Wed 02 Nov 2011 09:44

Re: Get execution timings

Post by Pinturiccio » Thu 18 Dec 2014 15:06

OracleMonitor class has the TraceEvent event that allows getting duration of a fetch operation. For more information, please refer to http://www.devart.com/dotconnect/oracle ... nt_EV.html

Here is the example, demonstrating how to get duration of a fetch operation with this event.
In your case, the duration of the fetch operation is equal to the duration of preparing and executing the statement:

Code: Select all

static void Main(string[] args)
{
    OracleMonitor mon = new OracleMonitor();
    mon.IsActive = true;
    mon.TraceEvent += new Devart.Common.MonitorEventHandler(mon_TraceEvent);
    OracleConnection conn = new OracleConnection("your connection string");
    conn.Open();
    OracleCommand comm = new OracleCommand("select * from dept", conn);
    var reader = comm.ExecuteReader();
}

static void mon_TraceEvent(object sender, Devart.Common.MonitorEventArgs e)
{
    if (e.TracePoint == MonitorTracePoint.AfterEvent&&(e.EventType==MonitorEventType.Execute||e.EventType==MonitorEventType.Prepare))
    {
        Console.WriteLine("Description: " + e.Description);
        Console.WriteLine(" Duration: " + e.Duration);
    }
}

Partizan
Posts: 36
Joined: Fri 13 Nov 2009 10:18

Re: Get execution timings

Post by Partizan » Thu 18 Dec 2014 17:03

Hi Pinturiccio,

Thanks for the prompt response!
Does that include time of iterating through data reader and getting all the data loaded on the client?

Our queries are produced by Entity Framework (we use Entity Developer for our model).
Is there any way for us to get elapsed time between the query was sent to Oracle and Devart's internal data reader finished with enumerating data to provide that to the upper layer?

Thank you.

Shalex
Devart Team
Posts: 8033
Joined: Thu 14 Aug 2008 12:44

Re: Get execution timings

Post by Shalex » Fri 19 Dec 2014 16:34

Partizan wrote:Does that include time of iterating through data reader and getting all the data loaded on the client?
No, this is the time to wait for any server reply since the command was sent to a server, and it doesn't include the time necessary to fetch data if the command selects some data.
Partizan wrote:Is there any way for us to get elapsed time between the query was sent to Oracle and Devart's internal data reader finished with enumerating data to provide that to the upper layer?
Our EF provider is not shipped with any embedded tools for this task. You should implement metrics in your code.

Post Reply