Cache Up to the Caching Application Block in Enterprise Library 3.0
Any application you write may require some sort of caching to meet the performance requirements of the business. Until the release of Enterprise Library, developers were forced to roll out their own caching implementations; however, developers now finally have a standard out-of-the-box caching solution that is fully tested—and it's free! The Caching Application Block provides a flexible and extensible caching mechanism that can be used at any or all layers of an application. It supports in-memory, database, or isolated storage stores for persisting the cached data. It also includes a set of very easy-to-use APIs that let you incorporate standard caching operations into your applications without needing to learn the complexities of the caching implementation. This article introduces the Caching Application Block and shows examples of how to use it to write robust caching implementations.
Boost ASP.NET Performance with Precompilation
The latest version of ASP.NET, version 2.0, supports several new and exciting features that promise to enhance developer productivity, administration and management, extensibility, and performance. One of these features is precompilation, which either developers or administrators can use to precompile ASP.NET applications before they are deployed. Moreover, the new precompilation feature can detect and provide warnings about any compilation failure issues, and lets you deploy applications without the need to store the source code on the deployment server. Precompilation can both reduce application response time and improve performance. This article explains how to use the new feature effectively.
Speed Test: Switch vs If-Else-If
The .NET framework and the C# language provide two methods for conditional processing where multiple discrete values can be selected from. The switch statement is less flexible than the if-else-if ladder but is generally considered to be more efficient.
Speed Testing and the Stopwatch Class
Software must operate at a speed that is acceptable to the end user. Often large improvements can be made by improving the speed of short-lived but heavily used routines. The speed of these can be accurately measured using the .NET 2.0 Stopwatch class.
Improving ASP.NET Application Performance and Scalability
Explore ways to reduce page load time, manage state efficiently, scale back on memory use, handle resources better, and improve data access in your ASP.NET applications.
Output Caching in ASP.NET 2.0
One of the most sure-fire ways to improve a web application's performance is to employ caching. Caching takes some expensive
operation and stores its results in a quickly accessible location. ASP.NET
version 1.0 introduced two flavors of caching:
- Output Caching - caches the entire rendered markup of an ASP.NET web page or User
Control for a specified duration.
- Data Caching - a programmatically-accessible, in-memory data cache for storing objects in the web server's memory.
For a more in-depth discussion on ASP.NET 1.x's caching capabilities, refer to Scott McFarland's Caching
with ASP.NET and Steve Smith's ASP.NET Caching:
Techniques and Best Practices articles.
In ASP.NET 2.0, the caching system has been extended to include
SQL cache dependencies, cache profiles,
and post-cache substitution for output cached pages. The Caching
for Performance section of the ASP.NET 2.0 QuickStarts
provides a good overview of ASP.NET 2.0's caching options.
This article explores output caching in ASP.NET 2.0, starting with an overview of output caching and followed by a detailed
look at creating pages that include both cached and non-cached markup using fragment caching and post-cache substitution
techniques.
Speed Optimization with page and server controls, web application settings and coding practices
ASP.NET Applications speed optimizations regarding to use of page and server controls, web application settings and best coding practices
Performance Console (PerfConsole)
The PerfConsole allows developers to analyze Visual Studio Performance Profiler's reports. It is a simple performance investigation tool which tries to adopt a debugger like experience to drilling into Visual Studio Performance Profiler generated data.
System.Diagnostics.Stopwatch - always remember to use Reset
Wrong
System.Diagnostics.Stopwatch s = new System.Diagnostics.Stopwatch();
s.Start();
for (i = 0; i < count; i++) Test1();
s.Stop();
Console.WriteLine("Test1: {0}", s.ElapsedMilliseconds);
s.Start();
for (i = 0; i < count; i++) Test2();
s.Stop();
Console.WriteLine("Test2: {0}", s.ElapsedMilliseconds);
Right
System.Diagnostics.Stopwatch s = new System.Diagnostics.Stopwatch();
s.Start();
for (i = 0; i < count; i++) Test1();
s.Stop();
Console.WriteLine("Test1: {0}", s.ElapsedMilliseconds);
s.Reset();
s.Start();
for (i = 0; i < count; i++) Test2();
s.Stop();
Console.WriteLine("Test2: {0}", s.ElapsedMilliseconds);
Not that *cough* I would ever make this mistake or anything, but you know... it could happen to like, a friend, or something. Ya. My friend. :)
.NET Offers a "First Chance" to Squelch Performance-killing Hidden Exceptions
Uncaught exceptions in your .NET applications can turn an otherwise high-performance application into a snail, especially those that are allowed to be "eaten" by subsequent code. Find out how to use very handy "First Chance" exception feature in the .NET debugger to root out nasty hidden exceptions.