.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 of a JIRA Workflow for Web Development 17th April, 2018

How To Solve: SQL Server detected a logical consistency-based I/O error: invalid protection option. 19th March, 2018

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.

View Comments (0) ...
Navigation