.NET Daily

Performance Test: Inline Code vs. DataBound Event

Introduction

Darius

Darius

Darius Dumitrescu is a creative Senior CMS Consultant with in depth .NET knowledge, focused on Web Development and Architecture Design.


LATEST POSTS

My View on the Life cycle of a Fixed Cost Web Project 01st July, 2018

How to Deliver Accurate Project Status Reports 21st April, 2018

Microsoft ASP.NET

Performance Test: Inline Code vs. DataBound Event

Posted on .

I always wanted to know the difference in terms performance between the two methods but I’ve never put them into “battle”.

So, I’ve created an asp.net solution, I added two pages with two GridViews and a SQL Server 2008 Compact Database with over 5000 entries and I’ve put them to the test:

Here are the results!

DataBound event method:

  • first load: 2,57s;
  • second page on GridView: 1,96s;
  • third page on GridView: 2,89s;
  • first page again on GridView: 2,76s;

Inline code method:

  • first load: 2,76s;
  • second page on GridView: 3,52s;
  • second page on GridView: 2,31s;
  • first page again on GridView: 2,92s;

Results may vary depending on each computer configuration.

The difference in performance between the two examples is very little, almost unnoticed. But the time spent in development is way different.
When using the method with inline code, development takes up to three times less than the one with DataBound event. Same thing with lines of code written.

Download the Visual Studio test example solution from below.

Attachments

Darius

Darius

Darius Dumitrescu is a creative Senior CMS Consultant with in depth .NET knowledge, focused on Web Development and Architecture Design.

There are no comments.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

View Comments (0) ...
Navigation