Dear MVP - Web control performance enquiries

Discussion in 'ASP .Net' started by =?Utf-8?B?QXNoYQ==?=, Sep 24, 2004.

  1. Dear MVP,

    A small question to you all
    Lets say I have an application which gets the value from a drop down list,
    e.g.

    GetProductInfo1(ddl.selectedItem.value)
    GetProductInfo2(ddl.selectedItem.value)
    GetProductInfo3(ddl.selectedItem.value)
    GetProductInfo4(ddl.selectedItem.value)
    GetProductInfo5(ddl.selectedItem.value)

    If you notice, I’m repeating ddl.selectedItem.value 5 times, would it be
    better if I just put it into a variable e.g.

    Dim int as integer

    Int = ddl.selectedItem.value

    And from there I just use the variable when ever I need it, rather then
    having it call this stmt ddl.selectedItem.value. would it improve performance?

    Thanks for taking the time to read this post.
    =?Utf-8?B?QXNoYQ==?=, Sep 24, 2004
    #1
    1. Advertising

  2. Hi,

    I'm not an MVP but I can answer this for you. If you are just using it 5
    times you will not notice much of a performance boost by putting it into a
    variable. However, if you were using this in a loop that had a ton of
    iterations you would see a *small* gain in performance. Also it looks like
    your GetProductInfoX() functions take an Integer. So by doing this:

    Dim int as Integer
    int = CInt(ddl.SelectedItem.Value)

    And then using int in your function calls you will also increase performance
    because the CLR won't have to perform the conversion 5 times. Again, since
    it is only used 5 times the performance will hardly be measurable. But if
    this was in a loop then the conversion for each iteration would cost you a
    little bit.

    By putting Option Strict On at the beginning of each code file you will see
    where the CLR is doing all your conversions for you. If they are in loops
    then doing the conversion yourself and using the result will optimize your
    code. It could also help you catch tricky errors that occur when the CLR
    tries to figure out what your trying to do but gets it wrong. Good luck!
    Ken.

    --
    Ken Dopierala Jr.
    For great ASP.Net web hosting try:
    http://www.webhost4life.com/default.asp?refid=Spinlight

    "Asha" <> wrote in message
    news:D...
    >
    > Dear MVP,
    >
    > A small question to you all
    > Lets say I have an application which gets the value from a drop down list,
    > e.g.
    >
    > GetProductInfo1(ddl.selectedItem.value)
    > GetProductInfo2(ddl.selectedItem.value)
    > GetProductInfo3(ddl.selectedItem.value)
    > GetProductInfo4(ddl.selectedItem.value)
    > GetProductInfo5(ddl.selectedItem.value)
    >
    > If you notice, I'm repeating ddl.selectedItem.value 5 times, would it be
    > better if I just put it into a variable e.g.
    >
    > Dim int as integer
    >
    > Int = ddl.selectedItem.value
    >
    > And from there I just use the variable when ever I need it, rather then
    > having it call this stmt ddl.selectedItem.value. would it improve

    performance?
    >
    > Thanks for taking the time to read this post.
    >
    >
    Ken Dopierala Jr., Sep 24, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darren
    Replies:
    0
    Views:
    276
    Darren
    Jan 26, 2004
  2. =?Utf-8?B?QXNoYQ==?=

    Dear MVP - Web control performance enquiries

    =?Utf-8?B?QXNoYQ==?=, Sep 24, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    381
    Scott Allen
    Sep 24, 2004
  3. =?Utf-8?B?QXNoYQ==?=

    Dear MVP; ASP.NET 2.0 combo box questions.

    =?Utf-8?B?QXNoYQ==?=, Oct 7, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,792
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN
    Oct 7, 2004
  4. Darren

    Counting partner enquiries and setting daily maximum.

    Darren, Jan 26, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    100
    Darren
    Jan 26, 2004
  5. Steven Burn

    Warning: MVP.org is not a Microsoft MVP site

    Steven Burn, Jan 10, 2004, in forum: ASP General
    Replies:
    7
    Views:
    161
    Jeff Cochran
    Jan 12, 2004
Loading...

Share This Page