Groups | Blog | Home
all groups > dotnet performance > may 2006 >

dotnet performance : ASP.NET 2.0 data-access classes : static methods, singletons



John A Grandy
5/1/2006 4:32:43 PM
I'm trying to determine the relative performance of three implementations of
data-access classes in ASP.NET 2.0 :

1. non-singleton classes with non-static methods which must
instantiate a class object (possibly multiple times) in each method
involved in processing a page request

2. singleton classes that implement a getInstance() method that
provides a pre-existing instance of the class if one exists; if an
instance does not exist, getInstance() instantiates a class object and
assigns it to an internal static reference

3. classes where all data-provision methods in the interface are
implemented as static methods


In the course of writing a scalable ASP.NET 2.0 web-app, has anyone done any
benchmarking (either formal or informal) ... or has a general sense of the
relative peformance of these 3 implementations ?

Does anyone know of any whitepapers or other studies that might be available
( either MS or external ) ?







David Browne
5/2/2006 1:06:48 PM

[quoted text, click to view]

This is probably the least efficient, but that's exactly the model that the
ASP.NET Page class uses. And that works pretty well. I don't think you
will see any improvement in your application scalability from one approach
or another. They simply differ on the wrong order of magnitude to matter.

In a web applicaiton the two data items that will really drive your
performance are

-caching static and semi-static data
-efficient SQL queries

David

Greg Young
5/2/2006 4:35:32 PM
I have to agree with David here ..

The difference between calling a singleton and calling a static method is
trivial compared to an inefficient query (or even a missed packet :))

If you have a single query that takes 100 ms longer than "optimal" running
that query 10 times is equivalent to millions of these calls.

A more specific answer though is that the singleton will be marginally
slower than static methods (because you have to obtain the singleton). The
singleton is however also much mroe flexible as it can do things such as
implement an interface which static methods cannot.

Cheers,

Greg
[quoted text, click to view]

AddThis Social Bookmark Button