Groups | Blog | Home
all groups > asp.net > june 2004 >

asp.net : Application[] and Session[]



Just D
6/23/2004 11:35:06 PM
Hi,

How slowly is to work with these objects - Application[] and Session[] ? Is
it much better to create a huge project or some static library and place all
variables/constants there instead of many Session[] objects?

When I removed some of Session[] objects and replaced by another approaches
I got an illusion that application started working significantly faster? Is
it true?

Did anybody try to evaluate how slow are these objects?

Thanks,
Dmitri
Just D
6/24/2004 1:52:36 AM
Hi Hans,

Thank you, I understand why do I need Session[] and Application[]. The
problem is that I'm currently optimizing the application that has been
written before me and later with my participation. The first author used a
lot of variables for everything and I'm trying to move some constants to a
static class and all session-related objects and variables to a huge object,
stored into session[] instead of a few hundreds of Session[] objects. It
makes sense, but I was wondering if anybody tested how slowly is to use
Session[] comparing to other methods, including a separate Class Library
with static members. Just it.

Thanks,
Dmitri

"Hans Kesting"

[quoted text, click to view]
Scott Allen
6/24/2004 9:34:43 AM
Hi Dimitri:

It's a relative answer that depends on how many objects, the type of
the objects, and where you keep session state (in memory, shared
server, or SQL Server). The Application object can easily be avoided,
Session is not so easy. Do some refactoring and then test to see if
your performance has improved.

I have some other thoughts typed up in these articles:

http://www.odetocode.com/Articles/83.aspx
http://odetocode.com/Articles/89.aspx

HTH!

--
Scott
http://www.OdeToCode.com


[quoted text, click to view]
Hans Kesting
6/24/2004 9:53:03 AM

[quoted text, click to view]

What are you storing? Lots of int's for example? Then you get
lots of boxing/unboxing operations. In this case it might be better
to define a class to store a number of int's (that are "natural" to
store together), so ytou can store a reference to that single class.

You can't easily change Session into static variables: Session is
user-specific (or rather "session specific" :-) ), and "static" is
application-wide.

Hans Kesting

MattC
6/24/2004 11:23:01 AM
Could you not move the constants to a resource file then load them into a
static class at application start up. Or create a cache source with a
dependency set to an xml file holding your constants?

MattC


[quoted text, click to view]

John Saunders
6/27/2004 9:27:38 PM
[quoted text, click to view]

How many such variables will you be using?

The performance is probably not worth worrying about. My philosophy is to
get the code to work first, then to worry about performance. Of course, this
assumes I don't do something brain-dead to make the performance so bad that
QA refuses to test it!

Also, pay no attention to performance the first time the application starts
after you change the application or web.config. When the application first
starts, everything gets recompiled. You should check performance by running
the same test multiple times and averaging the performance.

--
John Saunders
johnwsaundersiii at hotmail

AddThis Social Bookmark Button