SlideShare a Scribd company logo
DEV411  ASP.NET:  Best Practices For Performance Stephen Walther www.SuperexpertTraining.com
Purpose of Talk What is the fastest method of displaying a set of database records in an ASP.NET Page?
Testing Tools Trace Tools Profiler Tools Load Tools
Trace Tools ASP.NET Page or Application Tracing Display trace information on page System.Diagnostics Tracing Write trace information to custom listener
Trace Tools
Profiler Tools CLR Profiler Free Profiler from Microsoft ANTS Profiler Available at www.Red-Gate.com SQL Profiler Included with Microsoft SQL Server
ANTS Profiler
Load Tools Application Center Test Included with Visual Studio .NET Enterprise Web Application Stress Tool (WAST) Free download from Microsoft site ANTS Load Available at www.Red-Gate.com. Includes calculated Frustration Coefficient
Test Setup Application Center Test (ACT) .NET Framework 1.1 SQL Server 2000 Windows Server 2003 (Standard)
Performance Statistics Requests Per Second (RPS) Time To Last Byte (TTLB) Page Execution Time
Timer Module The Timer Module records the time interval between PreRequestHandlerExecute Event PostRequestHandlerExecute Event
Timer Module PostRequestEventHandlerExecute EndRequest Load Init Unload TimerModule.cs PreRequestEventHandlerExecute BeginRequest Application Events Page Events
Clock Resolution QueryPerformanceCounter is accurate to 1/3579545 of a second or about a millionth of a second
The Test Request page 1050 times Discard first 50 requests Log time of each request Average results
Database Setup Four Database Tables Products10 – 10 Rows Products50 – 50 Rows Products100 – 100 Rows Products500 – 500 Rows
What’s Faster? DataReader DataSet DisplayDataReader.aspx DisplayDataSet.aspx
DataReader
DataSet
DataReader Versus DataSet
DataReader Versus DataSet Final Results On average, a DataReader is 16% faster than DataSet
3rd Option – ArrayList Using an ArrayList instead of a DataReader results in similar performance with the advantages of a static representation of data DisplayArrayList.aspx
ArrayList
What’s Faster? SqlDataReader OleDbDataReader
OleDbDataReader
OleDbDataReader Final Results On average, a SqlDataReader is 115% faster than an OleDbDataReader
What’s Faster? Inline SQL Stored Procedure
Stored Procedure
What’s Faster? DataReader Column Reference By Name: Response.Write(dr[“ProductName”]); By Ordinal: Response.Write(dr[0]); By GetString(): Response.Write(dr.GetString(0));
Column Reference
Column Reference Final Results On average, ordinal reference is 11% faster than by name
What’s Faster? Proper Case dr[“ProductName”] Improper Case dr[“PRODUCTNAME”]
Proper Case
Proper Case Final Results Using proper column case is 1% faster than improper column case
What’s Faster? Inline ASP.NET Controls
DataGrid
DataGrid Final Results Inline script is 233% faster than a DataGrid
What’s Faster? DataGrid with ViewState Disabled DataGrid with ViewState Enabled
ViewState
ViewState Final Results DataGrid with ViewState disabled is 66% faster than DataGrid with ViewState enabled
What’s Faster? AutoGenerateColumns Template Columns
Template Columns
Template Columns Final Results A DataGrid without templates is 39% faster than a DataGrid with templates
What’s Faster? How to improve template performance? DataBinder.Eval <%# DataBinder.Eval(Container.DataItem, “ProductName”) %> Explicit Cast <%# ((DbDataRecord)Container.DataItem)[&quot;ProductName&quot;]%> ItemDataBound void ItemDataBound(Object s, DataGridItemEventArgs e) DisplayItemDataBound.aspx
Template Performance
Template Performance Final Results Explicit cast is 11% faster than using a databinding expression
Creating A Custom Control Would a custom DataGrid (with severely reduced functionality) be faster than the standard DataGrid? FastGrid.cs
Custom Control
Custom Control Final Results FastGrid is 37% faster than a standard DataGrid
What’s Faster? DataGrid with no caching DataGrid with data caching DataGrid with output caching
Data Caching
Data Cache Final Results Using the data cache is 637% faster than a standard DataGrid
Output Cache
Output Cache Final Results Using the output cache is infinitely faster than using a standard DataGrid
Conclusions A DataReader is faster than a DataSet An inline DataReader is faster than a DataGrid You pay a high price for ViewState AutoGenerateColumns is faster than template columns Caching is always a good idea!
Performance Resources Microsoft Sites Performance http://msdn.microsoft.com/netframework/using/understanding/perf/default.aspx Books Improving .NET Application Performance and Scalability http://msdn.microsoft.com/library/en-us/dnpag/html/scalenet.asp Software Web Application Stress Tool http://www.microsoft.com/technet/itsolutions/intranet/downloads/webstres.mspx CLR Profiler http://www.microsoft.com/downloads/details.aspx?FamilyID=86ce6052-d7f4-4aeb-9b7a-94635beebdda&displaylang=en ANTS Profiler and ANTS Load http://www.Red-Gate.com
Q1: Overall satisfaction with the session Q2: Usefulness of the information Q3: Presenter’s knowledge of the subject Q4: Presenter’s presentation skills Q5: Effectiveness of the presentation Please fill out a session evaluation on CommNet

More Related Content

PPTX
Advanced .NET Data Access with Dapper
PPTX
Advanced data access with Dapper
PPTX
Dapper performance
PPTX
Angular JS deep dive
PPTX
PDF
Degrading Performance? You Might be Suffering From the Small Files Syndrome
PDF
Using the python_data_toolkit_timbers_slides
PDF
Secrets of highly_avail_oltp_archs
Advanced .NET Data Access with Dapper
Advanced data access with Dapper
Dapper performance
Angular JS deep dive
Degrading Performance? You Might be Suffering From the Small Files Syndrome
Using the python_data_toolkit_timbers_slides
Secrets of highly_avail_oltp_archs

What's hot (20)

PDF
Bulletproof Jobs: Patterns For Large-Scale Spark Processing
PDF
SASI, Cassandra on the full text search ride - DuyHai Doan - Codemotion Milan...
PDF
Scaling Self Service Analytics with Databricks and Apache Spark with Amelia C...
PPT
Configuring elasticsearch for performance and scale
PPTX
How Rackspace Cloud Monitoring uses Cassandra
PPTX
Multi dimension aggregations using spark and dataframes
PDF
Apache Calcite: One planner fits all
PDF
Elasticsearch and Spark
PDF
Scaling massive elastic search clusters - Rafał Kuć - Sematext
PDF
Side by Side with Elasticsearch & Solr, Part 2
PDF
Getting started with Apollo Client and GraphQL
PDF
DOD 2016 - Rafał Kuć - Building a Resilient Log Aggregation Pipeline Using El...
PDF
Qtp connect to an oracle database database - database skill
PPT
Building a CRM on top of ElasticSearch
PDF
User Defined Partitioning on PlazmaDB
PDF
Real-time Machine Learning Analytics Using Structured Streaming and Kinesis F...
PDF
Lighthouse - an open-source library to build data lakes - Kris Peeters
PDF
Real-Time Spark: From Interactive Queries to Streaming
PDF
Introduction to TitanDB
PDF
Galaxy
Bulletproof Jobs: Patterns For Large-Scale Spark Processing
SASI, Cassandra on the full text search ride - DuyHai Doan - Codemotion Milan...
Scaling Self Service Analytics with Databricks and Apache Spark with Amelia C...
Configuring elasticsearch for performance and scale
How Rackspace Cloud Monitoring uses Cassandra
Multi dimension aggregations using spark and dataframes
Apache Calcite: One planner fits all
Elasticsearch and Spark
Scaling massive elastic search clusters - Rafał Kuć - Sematext
Side by Side with Elasticsearch & Solr, Part 2
Getting started with Apollo Client and GraphQL
DOD 2016 - Rafał Kuć - Building a Resilient Log Aggregation Pipeline Using El...
Qtp connect to an oracle database database - database skill
Building a CRM on top of ElasticSearch
User Defined Partitioning on PlazmaDB
Real-time Machine Learning Analytics Using Structured Streaming and Kinesis F...
Lighthouse - an open-source library to build data lakes - Kris Peeters
Real-Time Spark: From Interactive Queries to Streaming
Introduction to TitanDB
Galaxy
Ad

Viewers also liked (9)

PPT
Dev308
PPTX
What is new in .NET 4.5
PPTX
New features in .NET 4.5, C# and VS2012
KEY
Vim week
PDF
WPF 06 - personalizando los controles de interfaz de usuario
PDF
How I Accidentally Discovered MVVM
PPT
Simple Data Binding
PDF
WPF 03 - controles WPF
PPTX
Wpf Validation
Dev308
What is new in .NET 4.5
New features in .NET 4.5, C# and VS2012
Vim week
WPF 06 - personalizando los controles de interfaz de usuario
How I Accidentally Discovered MVVM
Simple Data Binding
WPF 03 - controles WPF
Wpf Validation
Ad

Similar to Dev411 (20)

PPT
DataFinder: A Python Application for Scientific Data Management
PPT
Organizing the Data Chaos of Scientists
PPTX
Practical OData
PPTX
Ch 7 data binding
PPT
Unity JDBC ICEIS ppt UnityJDBC ICEIS ppt
PPT
2310 b 10
PPTX
ADO.NET by ASP.NET Development Company in india
PPT
2005 - .NET Chaostage: 1st class data driven applications with ASP.NET 2.0
PPTX
Windows Azure Acid Test
PPT
Enterprise Library 2.0
PDF
Data access
PDF
Data Seeding via Parameterized API Requests
PPTX
Scaling asp.net websites to millions of users
PPTX
The Best Way to Become an Android Developer Expert with Android Jetpack
PPT
DataFinder concepts and example: General (20100503)
PPTX
Why Standards-Based Drivers Offer Better API Integration
PDF
6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...
PPT
Pragmatic Parallels: Java and JavaScript
PPT
YDP_API&MS_UNIT_IIIii8iiiiiiiii8iiii.ppt
PPT
YDP_API&MS_UNIT_hiii detail notes to understand api.ppt
DataFinder: A Python Application for Scientific Data Management
Organizing the Data Chaos of Scientists
Practical OData
Ch 7 data binding
Unity JDBC ICEIS ppt UnityJDBC ICEIS ppt
2310 b 10
ADO.NET by ASP.NET Development Company in india
2005 - .NET Chaostage: 1st class data driven applications with ASP.NET 2.0
Windows Azure Acid Test
Enterprise Library 2.0
Data access
Data Seeding via Parameterized API Requests
Scaling asp.net websites to millions of users
The Best Way to Become an Android Developer Expert with Android Jetpack
DataFinder concepts and example: General (20100503)
Why Standards-Based Drivers Offer Better API Integration
6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...
Pragmatic Parallels: Java and JavaScript
YDP_API&MS_UNIT_IIIii8iiiiiiiii8iiii.ppt
YDP_API&MS_UNIT_hiii detail notes to understand api.ppt

Recently uploaded (20)

PDF
Approach and Philosophy of On baking technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Spectroscopy.pptx food analysis technology
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Machine Learning_overview_presentation.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Machine learning based COVID-19 study performance prediction
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Empathic Computing: Creating Shared Understanding
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Encapsulation theory and applications.pdf
Approach and Philosophy of On baking technology
Reach Out and Touch Someone: Haptics and Empathic Computing
Spectroscopy.pptx food analysis technology
“AI and Expert System Decision Support & Business Intelligence Systems”
Machine Learning_overview_presentation.pptx
A Presentation on Artificial Intelligence
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Programs and apps: productivity, graphics, security and other tools
Machine learning based COVID-19 study performance prediction
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
The AUB Centre for AI in Media Proposal.docx
Per capita expenditure prediction using model stacking based on satellite ima...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
MIND Revenue Release Quarter 2 2025 Press Release
Empathic Computing: Creating Shared Understanding
Assigned Numbers - 2025 - Bluetooth® Document
Diabetes mellitus diagnosis method based random forest with bat algorithm
Encapsulation theory and applications.pdf

Dev411