Performance DAAB

Topics: Data Access Application Block, General discussion
Aug 10, 2009 at 2:33 PM

run storeprocedure (20,000 entries) Ado.net time was less than DAAB.

attached source code, which has advantages DAAB / Ado.net

Performance advantages please

 

Best regards

 

 

 

ADO.net

 

string str = "Data Source=ACT-27838\\SQLEXPRESS;Initial Catalog=Northwind;User;Password=jazavala;";

            System.Diagnostics.Stopwatch watch = new Stopwatch();

            System.Diagnostics.Stopwatch watchTotal = new Stopwatch();

 

            bindingSource.Clear();

 

            watchTotal.Start();

            watch.Start();

 

            SqlConnection con = new SqlConnection(str);

            con.Open();

 

            SqlCommand cmd = new SqlCommand("SELECT * FRom Performance", con);

            cmd.CommandType=CommandType.Text;  

            SqlDataReader dr=cmd.ExecuteReader();

           

            watch.Stop();

           

            lblAdoDatos.Text = String.Format("Tiempo consumido en extraer los datos: {0}", watch.ElapsedMilliseconds.ToString());

           

           

            watch.Reset();

            watch.Start();

            //

            bindingSource.DataSource = dr;

            dataGridView1.DataSource = bindingSource;

            watch.Stop();

 

            lblDatosCargar.Text=String.Format("Tiempo que tardo en Mostrar los datos: {0}", watch.ElapsedMilliseconds.ToString());

 

            con.Close();

 

            watchTotal.Stop();

 

            lblTotal.Text = String.Format("Tiempo Total: {0}", watchTotal.ElapsedMilliseconds.ToString());

 

 

DAAB

 

string str = "Data Source=ACT-27838\\SQLEXPRESS;Initial Catalog=Northwind;User;Password=jazavala;";

            Stopwatch wTotal = new Stopwatch();

            Stopwatch w = new Stopwatch();

 

            bindingSource.Clear();                   

           

 

            wTotal.Start();

            w.Start();

 

            Database objDB = new SqlDatabase(str);

            IDataReader dr = objDB.ExecuteReader(CommandType.Text,"SELECT * FRom Performance");

 

            w.Stop();

            lblEntLibDatos.Text=string.Format("Tiempo consumido en extraer los datos: {0}",w.ElapsedMilliseconds.ToString());

 

            w.Reset();

            w.Start();

 

            bindingSource.DataSource = dr;

            dataGridView1.DataSource = bindingSource;

            dr.Close();

            w.Stop();

 

            lblEntLibCargar.Text = string.Format("Tiempo consumido en mostrar los datos: {0}", w.ElapsedMilliseconds.ToString());

 

            wTotal.Stop();

            lblTotalEnt.Text = string.Format("Tiempo Total: {0}", wTotal.ElapsedMilliseconds.ToString());

Aug 11, 2009 at 3:58 AM

I've already read in other forums that they consider the raw ADO.NET to be much faster than DAAB.  In the documentation, the advantages mentioned were really just referring to ease of use and support for different types of databases in an agnostic way.  Here's a sample benchmarking made between DAAB, ADO.NET and LINQ - http://alexpinsker.blogspot.com/2007/07/benchmarking-linq-vs.html.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com