Showing posts with label slow. Show all posts
Showing posts with label slow. Show all posts

Thursday, March 29, 2012

Performance on images.

I have a web application which contains loads of images.

when I load from our hosted site, its pretty slow. i can see every image as they were loading. sometimes images do not display until they are used ( e.g. mouseover a certain image panel )

Question is. what is the best practice of handling images to boost performance? currently i just place my images in a folder and use CSS to reference them.

Will it improve performance to use Resource files instead?

thanks!

the only way i can think of is to cache the page, but the first still needs time as physically, people have to download the images no matter what.

Hi,

The way u r doing is common thing and i think its the right way also.
this problem may be becasuse of poor bandwidth. Anyway it will be better to use image will less KB's


thank you for your inputs. one thing more is that I heavily use server controls, which I'm not really sure if it has any effect on performance... taking out the ViewState factor...

I just have one thing to consider, if you are dealing with large images you can create thumbnails out of these images which will decrease its size and increase the loading speed.

Create Thumbnail Images

HC


can you elaborate on what you mean please??

do you mean to use the code your probided in ur blog to create thumbnail images.. and use these images instead?


The code provided will create a thumbnail image from the original image with specified width and height (100 px, 100px) which will decrease its size and make the load process better. for example if you have an image size equals to 6 mb when you create a thumbnail it will be 24 kb or even less.

So what yo u can do is to programatically using the provided code create an thumbnails save them in a folder on your web server and load them instead of using the original images.

HC


hi,

i've read your problem thru. and i think both the above two solutions can solve you problem. you can use output caching in ur page,setting theDuration time a little ralatively longer andLoctaionto be 'Any'. For more information you can refer to:

ms-help://MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_aspnetcon/html/51149563-a347-4b2b-bdc2-57a317e12487.htm

Also you can follow haissam's suggestion to create thumbnail images for the original ones.

Well, i have another suggestion, you can choose to host your images to another web host( if you have got pretty pretty lots of images) which is much more powerful and stronger . This can make your access to the images much faster than now.

Hope my suggestion helps. :)


I appreciate all your responses. thank you very much.! =)

hi,

how do i open this link ? ms-help://MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_aspnetcon/html/51149563-a347-4b2b-bdc2-57a317e12487.htm


The 100 px x 100px.. is that fixed? or just need to set it same with the original height and oeiginal width?

so if you have an image 1000px by 400px... just set it to these values?


another thing, i'm getting "A generic error occurred in GDI+" error when saving the thumbnail. any ideaS?

oh, i assumed that u have an msdn installed on your local computer. i'm sorry. you can still refer to :http://msdn2.microsoft.com/en-us/library/zd1ysf1y(VS.80).aspx

it's the same :)

performance question

Lets just say my app is done HOO HOO.

Now, I'm accessing the database via a web service and one thing i noticed
that my app is running real slow. When I first started working on the app is
ran pretty quick returned the data to the screens in about 2 - 3 seconds. Now
its going about 5 - 10 seconds. How can I beef it up for better performance.> Lets just say my app is done HOO HOO.

I hate it when my app is done HOO HOO. But what are you going to do? Live it
or live with it, as the young lady says...

;-)

Performance. This is one of the reasons why Uncle Chutney says "Big things
are made up of lots of little things." In a client-server app, this is
especially true. Small increases or decreases in performance can make a big
difference when a lot of clients are accessing a web app. Multiply the
difference in performance by the number of clients, and you can see why.

There are lots of little things you can do to dramatically increase
performance. I'll try to hit the big ones.

1. In a client-server app, any work done by the client means a big savings
on the server. The more clients the bigger the savings. Use client-side
processing and JavaScript whenever possible.
2. If your App is written in VB.Net, make sure that Option Strict is turned
ON! Late-binding is anathema to performance.
3. Avoid duplication in your app. Don't duplicate values, and don't
duplicate code. Any time you see the same few lines of code in several
places, you're looking at a good candidate for a function or Sub. If you
have created a number of classes that have the same fields, properties,
and/or methods, you're looking at a good candidate for a base class, and
derived classes.
4. Avoid using the "drag and drop" tools in the toolbox. Some of them are
quite useful; others are one-size-fits-all memory hogs for beginners, to
make it easy for them to make something happen without much trouble.
5. Close and/or Dispose any objects that use unmanaged resources as quickly
as possible.
6. Close database connections ASAP.

On a similar note, it should be stressed that performance is a factor in
designing your app. The fastest apps have much more lower-level code in
them, and are also more proprietary overall. Writing an app that is easily
extensible may involve a trade-off of performance over code maintainability.
Striking the right balance is an art.

I'm sure I've overlooked several things, but I do believe I've hit on the
majors in this list. At any rate, I hope it helps.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:1DA19F5F-C332-4818-959F-7881D0D3A61A@.microsoft.com...
> Lets just say my app is done HOO HOO.
> Now, I'm accessing the database via a web service and one thing i noticed
> that my app is running real slow. When I first started working on the app
is
> ran pretty quick returned the data to the screens in about 2 - 3 seconds.
Now
> its going about 5 - 10 seconds. How can I beef it up for better
performance.
All good points. Actually all the db connections are closed and all the db
transactions are being done in the web service. The html(aspx) pages call the
function needed and then i do formatting on the aspx pages, such as the
datagrids.
The only question i have it the Option Strict. I turned that ON and when I
recompiled the project. I got all kinds of errors such as

Option Strict On Disallows implicit conversions from 'String' to 'Short'

how do i fix that?

"Kevin Spencer" wrote:

> > Lets just say my app is done HOO HOO.
> I hate it when my app is done HOO HOO. But what are you going to do? Live it
> or live with it, as the young lady says...
> ;-)
> Performance. This is one of the reasons why Uncle Chutney says "Big things
> are made up of lots of little things." In a client-server app, this is
> especially true. Small increases or decreases in performance can make a big
> difference when a lot of clients are accessing a web app. Multiply the
> difference in performance by the number of clients, and you can see why.
> There are lots of little things you can do to dramatically increase
> performance. I'll try to hit the big ones.
> 1. In a client-server app, any work done by the client means a big savings
> on the server. The more clients the bigger the savings. Use client-side
> processing and JavaScript whenever possible.
> 2. If your App is written in VB.Net, make sure that Option Strict is turned
> ON! Late-binding is anathema to performance.
> 3. Avoid duplication in your app. Don't duplicate values, and don't
> duplicate code. Any time you see the same few lines of code in several
> places, you're looking at a good candidate for a function or Sub. If you
> have created a number of classes that have the same fields, properties,
> and/or methods, you're looking at a good candidate for a base class, and
> derived classes.
> 4. Avoid using the "drag and drop" tools in the toolbox. Some of them are
> quite useful; others are one-size-fits-all memory hogs for beginners, to
> make it easy for them to make something happen without much trouble.
> 5. Close and/or Dispose any objects that use unmanaged resources as quickly
> as possible.
> 6. Close database connections ASAP.
> On a similar note, it should be stressed that performance is a factor in
> designing your app. The fastest apps have much more lower-level code in
> them, and are also more proprietary overall. Writing an app that is easily
> extensible may involve a trade-off of performance over code maintainability.
> Striking the right balance is an art.
> I'm sure I've overlooked several things, but I do believe I've hit on the
> majors in this list. At any rate, I hope it helps.
> --
> HTH,
> Kevin Spencer
> ..Net Developer
> Microsoft MVP
> I get paid good money to
> solve puzzles for a living
> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> news:1DA19F5F-C332-4818-959F-7881D0D3A61A@.microsoft.com...
> > Lets just say my app is done HOO HOO.
> > Now, I'm accessing the database via a web service and one thing i noticed
> > that my app is running real slow. When I first started working on the app
> is
> > ran pretty quick returned the data to the screens in about 2 - 3 seconds.
> Now
> > its going about 5 - 10 seconds. How can I beef it up for better
> performance.
>
Dim x as string = "99"
Dim y as short = CType(x, Short)
OR
Dim y as short = CShort(x)

You'll use a lot of CType with Option Strict On, but it is worth the extra
effort.

Greg

"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:8AEAF9A6-319B-4298-AC79-2991C3F89A2A@.microsoft.com...
> All good points. Actually all the db connections are closed and all the db
> transactions are being done in the web service. The html(aspx) pages call
> the
> function needed and then i do formatting on the aspx pages, such as the
> datagrids.
> The only question i have it the Option Strict. I turned that ON and when I
> recompiled the project. I got all kinds of errors such as
> Option Strict On Disallows implicit conversions from 'String' to 'Short'
> how do i fix that?
> "Kevin Spencer" wrote:
>> > Lets just say my app is done HOO HOO.
>>
>> I hate it when my app is done HOO HOO. But what are you going to do? Live
>> it
>> or live with it, as the young lady says...
>>
>> ;-)
>>
>> Performance. This is one of the reasons why Uncle Chutney says "Big
>> things
>> are made up of lots of little things." In a client-server app, this is
>> especially true. Small increases or decreases in performance can make a
>> big
>> difference when a lot of clients are accessing a web app. Multiply the
>> difference in performance by the number of clients, and you can see why.
>>
>> There are lots of little things you can do to dramatically increase
>> performance. I'll try to hit the big ones.
>>
>> 1. In a client-server app, any work done by the client means a big
>> savings
>> on the server. The more clients the bigger the savings. Use client-side
>> processing and JavaScript whenever possible.
>> 2. If your App is written in VB.Net, make sure that Option Strict is
>> turned
>> ON! Late-binding is anathema to performance.
>> 3. Avoid duplication in your app. Don't duplicate values, and don't
>> duplicate code. Any time you see the same few lines of code in several
>> places, you're looking at a good candidate for a function or Sub. If you
>> have created a number of classes that have the same fields, properties,
>> and/or methods, you're looking at a good candidate for a base class, and
>> derived classes.
>> 4. Avoid using the "drag and drop" tools in the toolbox. Some of them are
>> quite useful; others are one-size-fits-all memory hogs for beginners, to
>> make it easy for them to make something happen without much trouble.
>> 5. Close and/or Dispose any objects that use unmanaged resources as
>> quickly
>> as possible.
>> 6. Close database connections ASAP.
>>
>> On a similar note, it should be stressed that performance is a factor in
>> designing your app. The fastest apps have much more lower-level code in
>> them, and are also more proprietary overall. Writing an app that is
>> easily
>> extensible may involve a trade-off of performance over code
>> maintainability.
>> Striking the right balance is an art.
>>
>> I'm sure I've overlooked several things, but I do believe I've hit on the
>> majors in this list. At any rate, I hope it helps.
>>
>> --
>> HTH,
>> Kevin Spencer
>> ..Net Developer
>> Microsoft MVP
>> I get paid good money to
>> solve puzzles for a living
>>
>> "Mike" <Mike@.discussions.microsoft.com> wrote in message
>> news:1DA19F5F-C332-4818-959F-7881D0D3A61A@.microsoft.com...
>> > Lets just say my app is done HOO HOO.
>>> > Now, I'm accessing the database via a web service and one thing i
>> > noticed
>> > that my app is running real slow. When I first started working on the
>> > app
>> is
>> > ran pretty quick returned the data to the screens in about 2 - 3
>> > seconds.
>> Now
>> > its going about 5 - 10 seconds. How can I beef it up for better
>> performance.
>>>>
>>
>
That worked on the one error.
Now i'm getting Option Strict On disallows Late binding.
I'm doing some formatting of the datagrids based on certain data that is
returned.

How can i fix that issue now?
I need to format the grids based on the data being returned

"Greg Burns" wrote:

> Dim x as string = "99"
> Dim y as short = CType(x, Short)
> OR
> Dim y as short = CShort(x)
> You'll use a lot of CType with Option Strict On, but it is worth the extra
> effort.
> Greg
> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> news:8AEAF9A6-319B-4298-AC79-2991C3F89A2A@.microsoft.com...
> > All good points. Actually all the db connections are closed and all the db
> > transactions are being done in the web service. The html(aspx) pages call
> > the
> > function needed and then i do formatting on the aspx pages, such as the
> > datagrids.
> > The only question i have it the Option Strict. I turned that ON and when I
> > recompiled the project. I got all kinds of errors such as
> > Option Strict On Disallows implicit conversions from 'String' to 'Short'
> > how do i fix that?
> > "Kevin Spencer" wrote:
> >> > Lets just say my app is done HOO HOO.
> >>
> >> I hate it when my app is done HOO HOO. But what are you going to do? Live
> >> it
> >> or live with it, as the young lady says...
> >>
> >> ;-)
> >>
> >> Performance. This is one of the reasons why Uncle Chutney says "Big
> >> things
> >> are made up of lots of little things." In a client-server app, this is
> >> especially true. Small increases or decreases in performance can make a
> >> big
> >> difference when a lot of clients are accessing a web app. Multiply the
> >> difference in performance by the number of clients, and you can see why.
> >>
> >> There are lots of little things you can do to dramatically increase
> >> performance. I'll try to hit the big ones.
> >>
> >> 1. In a client-server app, any work done by the client means a big
> >> savings
> >> on the server. The more clients the bigger the savings. Use client-side
> >> processing and JavaScript whenever possible.
> >> 2. If your App is written in VB.Net, make sure that Option Strict is
> >> turned
> >> ON! Late-binding is anathema to performance.
> >> 3. Avoid duplication in your app. Don't duplicate values, and don't
> >> duplicate code. Any time you see the same few lines of code in several
> >> places, you're looking at a good candidate for a function or Sub. If you
> >> have created a number of classes that have the same fields, properties,
> >> and/or methods, you're looking at a good candidate for a base class, and
> >> derived classes.
> >> 4. Avoid using the "drag and drop" tools in the toolbox. Some of them are
> >> quite useful; others are one-size-fits-all memory hogs for beginners, to
> >> make it easy for them to make something happen without much trouble.
> >> 5. Close and/or Dispose any objects that use unmanaged resources as
> >> quickly
> >> as possible.
> >> 6. Close database connections ASAP.
> >>
> >> On a similar note, it should be stressed that performance is a factor in
> >> designing your app. The fastest apps have much more lower-level code in
> >> them, and are also more proprietary overall. Writing an app that is
> >> easily
> >> extensible may involve a trade-off of performance over code
> >> maintainability.
> >> Striking the right balance is an art.
> >>
> >> I'm sure I've overlooked several things, but I do believe I've hit on the
> >> majors in this list. At any rate, I hope it helps.
> >>
> >> --
> >> HTH,
> >> Kevin Spencer
> >> ..Net Developer
> >> Microsoft MVP
> >> I get paid good money to
> >> solve puzzles for a living
> >>
> >> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> >> news:1DA19F5F-C332-4818-959F-7881D0D3A61A@.microsoft.com...
> >> > Lets just say my app is done HOO HOO.
> >> >> > Now, I'm accessing the database via a web service and one thing i
> >> > noticed
> >> > that my app is running real slow. When I first started working on the
> >> > app
> >> is
> >> > ran pretty quick returned the data to the screens in about 2 - 3
> >> > seconds.
> >> Now
> >> > its going about 5 - 10 seconds. How can I beef it up for better
> >> performance.
> >> >> >>
> >>
> >>
>
Hi Mike,

> The only question i have it the Option Strict. I turned that ON and when I
> recompiled the project. I got all kinds of errors such as

Awesome! Sounds like you're coming from a VB background. Option Strict
ensures that you use correct data types in your code. The difference between
late and early binding is that Late Binding means that your app explicitly
declares data types, and doesn't mix and match them. This way, the app
already knows at run-time how much memory to allocate for each object. When
late-binding is used, the data type of an object may NOT be known at
run-time, and the Platform has to figure out how much memory to allocate by
calculation, which often involves the use of Reflection. It can slow your
app down quite a bit.

The errors can be fixed by going through your code, and making sure that you
explicitly declare the correct data type for each field, property, or
variable that you are using. Also, avoid the use of the "Object" data type.
Object is the base class for ALL data types, and is therefore a
"late-binding class." So, for example, here is a field and Property declared
with no Data Types:

Private _DayOfWeek = 1
Public Property DayofWeek
Get
Return _DayOfWeek
End Get
Set (ByVal Value)
_DayOfWeek = Value
End Set
End Property

Using this (Option Strinct OFF), you could assign a TexBox value (always a
string) to DayOfWeek, and it would compile fine. At run-time, the String
would have to be converted to a number by the Platform.

Instead, you would put (Option Strict ON):

Private _DayOfWeek As Short = 1
Public Property DayofWeek As Short
Get
Return _DayOfWeek
End Get
Set (ByVal Value As Short)
_DayOfWeek = Value
End Set
End Property

Your code will compile fine, as long as nothing in your code tries to assign
a String to DayOfWeek. You will get a "Data Type Mismatch" error if you do.

As I'm sure you can see, this also prevents a lot of errors (assigning a
non-numeric string to be used as a Short, for example), as well as informing
the Platform to allocate 16 Bits for _DayOfWeek.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:8AEAF9A6-319B-4298-AC79-2991C3F89A2A@.microsoft.com...
> All good points. Actually all the db connections are closed and all the db
> transactions are being done in the web service. The html(aspx) pages call
the
> function needed and then i do formatting on the aspx pages, such as the
> datagrids.
> The only question i have it the Option Strict. I turned that ON and when I
> recompiled the project. I got all kinds of errors such as
> Option Strict On Disallows implicit conversions from 'String' to 'Short'
> how do i fix that?
> "Kevin Spencer" wrote:
> > > Lets just say my app is done HOO HOO.
> > I hate it when my app is done HOO HOO. But what are you going to do?
Live it
> > or live with it, as the young lady says...
> > ;-)
> > Performance. This is one of the reasons why Uncle Chutney says "Big
things
> > are made up of lots of little things." In a client-server app, this is
> > especially true. Small increases or decreases in performance can make a
big
> > difference when a lot of clients are accessing a web app. Multiply the
> > difference in performance by the number of clients, and you can see why.
> > There are lots of little things you can do to dramatically increase
> > performance. I'll try to hit the big ones.
> > 1. In a client-server app, any work done by the client means a big
savings
> > on the server. The more clients the bigger the savings. Use client-side
> > processing and JavaScript whenever possible.
> > 2. If your App is written in VB.Net, make sure that Option Strict is
turned
> > ON! Late-binding is anathema to performance.
> > 3. Avoid duplication in your app. Don't duplicate values, and don't
> > duplicate code. Any time you see the same few lines of code in several
> > places, you're looking at a good candidate for a function or Sub. If you
> > have created a number of classes that have the same fields, properties,
> > and/or methods, you're looking at a good candidate for a base class, and
> > derived classes.
> > 4. Avoid using the "drag and drop" tools in the toolbox. Some of them
are
> > quite useful; others are one-size-fits-all memory hogs for beginners, to
> > make it easy for them to make something happen without much trouble.
> > 5. Close and/or Dispose any objects that use unmanaged resources as
quickly
> > as possible.
> > 6. Close database connections ASAP.
> > On a similar note, it should be stressed that performance is a factor in
> > designing your app. The fastest apps have much more lower-level code in
> > them, and are also more proprietary overall. Writing an app that is
easily
> > extensible may involve a trade-off of performance over code
maintainability.
> > Striking the right balance is an art.
> > I'm sure I've overlooked several things, but I do believe I've hit on
the
> > majors in this list. At any rate, I hope it helps.
> > --
> > HTH,
> > Kevin Spencer
> > ..Net Developer
> > Microsoft MVP
> > I get paid good money to
> > solve puzzles for a living
> > "Mike" <Mike@.discussions.microsoft.com> wrote in message
> > news:1DA19F5F-C332-4818-959F-7881D0D3A61A@.microsoft.com...
> > > Lets just say my app is done HOO HOO.
> > > > Now, I'm accessing the database via a web service and one thing i
noticed
> > > that my app is running real slow. When I first started working on the
app
> > is
> > > ran pretty quick returned the data to the screens in about 2 - 3
seconds.
> > Now
> > > its going about 5 - 10 seconds. How can I beef it up for better
> > performance.
> >
Please post some code.

Greg

"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:24DE9539-DB6D-446D-A5BA-E7B6E4A19960@.microsoft.com...
> That worked on the one error.
> Now i'm getting Option Strict On disallows Late binding.
> I'm doing some formatting of the datagrids based on certain data that is
> returned.
> How can i fix that issue now?
> I need to format the grids based on the data being returned
> "Greg Burns" wrote:
>> Dim x as string = "99"
>> Dim y as short = CType(x, Short)
>> OR
>> Dim y as short = CShort(x)
>>
>> You'll use a lot of CType with Option Strict On, but it is worth the
>> extra
>> effort.
>>
>> Greg
>>
>> "Mike" <Mike@.discussions.microsoft.com> wrote in message
>> news:8AEAF9A6-319B-4298-AC79-2991C3F89A2A@.microsoft.com...
>> > All good points. Actually all the db connections are closed and all the
>> > db
>> > transactions are being done in the web service. The html(aspx) pages
>> > call
>> > the
>> > function needed and then i do formatting on the aspx pages, such as the
>> > datagrids.
>> > The only question i have it the Option Strict. I turned that ON and
>> > when I
>> > recompiled the project. I got all kinds of errors such as
>>> > Option Strict On Disallows implicit conversions from 'String' to
>> > 'Short'
>>> > how do i fix that?
>>> > "Kevin Spencer" wrote:
>>> >> > Lets just say my app is done HOO HOO.
>> >>
>> >> I hate it when my app is done HOO HOO. But what are you going to do?
>> >> Live
>> >> it
>> >> or live with it, as the young lady says...
>> >>
>> >> ;-)
>> >>
>> >> Performance. This is one of the reasons why Uncle Chutney says "Big
>> >> things
>> >> are made up of lots of little things." In a client-server app, this is
>> >> especially true. Small increases or decreases in performance can make
>> >> a
>> >> big
>> >> difference when a lot of clients are accessing a web app. Multiply the
>> >> difference in performance by the number of clients, and you can see
>> >> why.
>> >>
>> >> There are lots of little things you can do to dramatically increase
>> >> performance. I'll try to hit the big ones.
>> >>
>> >> 1. In a client-server app, any work done by the client means a big
>> >> savings
>> >> on the server. The more clients the bigger the savings. Use
>> >> client-side
>> >> processing and JavaScript whenever possible.
>> >> 2. If your App is written in VB.Net, make sure that Option Strict is
>> >> turned
>> >> ON! Late-binding is anathema to performance.
>> >> 3. Avoid duplication in your app. Don't duplicate values, and don't
>> >> duplicate code. Any time you see the same few lines of code in several
>> >> places, you're looking at a good candidate for a function or Sub. If
>> >> you
>> >> have created a number of classes that have the same fields,
>> >> properties,
>> >> and/or methods, you're looking at a good candidate for a base class,
>> >> and
>> >> derived classes.
>> >> 4. Avoid using the "drag and drop" tools in the toolbox. Some of them
>> >> are
>> >> quite useful; others are one-size-fits-all memory hogs for beginners,
>> >> to
>> >> make it easy for them to make something happen without much trouble.
>> >> 5. Close and/or Dispose any objects that use unmanaged resources as
>> >> quickly
>> >> as possible.
>> >> 6. Close database connections ASAP.
>> >>
>> >> On a similar note, it should be stressed that performance is a factor
>> >> in
>> >> designing your app. The fastest apps have much more lower-level code
>> >> in
>> >> them, and are also more proprietary overall. Writing an app that is
>> >> easily
>> >> extensible may involve a trade-off of performance over code
>> >> maintainability.
>> >> Striking the right balance is an art.
>> >>
>> >> I'm sure I've overlooked several things, but I do believe I've hit on
>> >> the
>> >> majors in this list. At any rate, I hope it helps.
>> >>
>> >> --
>> >> HTH,
>> >> Kevin Spencer
>> >> ..Net Developer
>> >> Microsoft MVP
>> >> I get paid good money to
>> >> solve puzzles for a living
>> >>
>> >> "Mike" <Mike@.discussions.microsoft.com> wrote in message
>> >> news:1DA19F5F-C332-4818-959F-7881D0D3A61A@.microsoft.com...
>> >> > Lets just say my app is done HOO HOO.
>> >>> >> > Now, I'm accessing the database via a web service and one thing i
>> >> > noticed
>> >> > that my app is running real slow. When I first started working on
>> >> > the
>> >> > app
>> >> is
>> >> > ran pretty quick returned the data to the screens in about 2 - 3
>> >> > seconds.
>> >> Now
>> >> > its going about 5 - 10 seconds. How can I beef it up for better
>> >> performance.
>> >>> >>> >>
>> >>
>> >>
>>
>>
>

performance question

Lets just say my app is done HOO HOO.
Now, I'm accessing the database via a web service and one thing i noticed
that my app is running real slow. When I first started working on the app is
ran pretty quick returned the data to the screens in about 2 - 3 seconds. No
w
its going about 5 - 10 seconds. How can I beef it up for better performance.> Lets just say my app is done HOO HOO.
I hate it when my app is done HOO HOO. But what are you going to do? Live it
or live with it, as the young lady says...
;-)
Performance. This is one of the reasons why Uncle Chutney says "Big things
are made up of lots of little things." In a client-server app, this is
especially true. Small increases or decreases in performance can make a big
difference when a lot of clients are accessing a web app. Multiply the
difference in performance by the number of clients, and you can see why.
There are lots of little things you can do to dramatically increase
performance. I'll try to hit the big ones.
1. In a client-server app, any work done by the client means a big savings
on the server. The more clients the bigger the savings. Use client-side
processing and JavaScript whenever possible.
2. If your App is written in VB.Net, make sure that Option Strict is turned
ON! Late-binding is anathema to performance.
3. Avoid duplication in your app. Don't duplicate values, and don't
duplicate code. Any time you see the same few lines of code in several
places, you're looking at a good candidate for a function or Sub. If you
have created a number of classes that have the same fields, properties,
and/or methods, you're looking at a good candidate for a base class, and
derived classes.
4. Avoid using the "drag and drop" tools in the toolbox. Some of them are
quite useful; others are one-size-fits-all memory hogs for beginners, to
make it easy for them to make something happen without much trouble.
5. Close and/or Dispose any objects that use unmanaged resources as quickly
as possible.
6. Close database connections ASAP.
On a similar note, it should be stressed that performance is a factor in
designing your app. The fastest apps have much more lower-level code in
them, and are also more proprietary overall. Writing an app that is easily
extensible may involve a trade-off of performance over code maintainability.
Striking the right balance is an art.
I'm sure I've overlooked several things, but I do believe I've hit on the
majors in this list. At any rate, I hope it helps.
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:1DA19F5F-C332-4818-959F-7881D0D3A61A@.microsoft.com...
> Lets just say my app is done HOO HOO.
> Now, I'm accessing the database via a web service and one thing i noticed
> that my app is running real slow. When I first started working on the app
is
> ran pretty quick returned the data to the screens in about 2 - 3 seconds.
Now
> its going about 5 - 10 seconds. How can I beef it up for better
performance.
>
All good points. Actually all the db connections are closed and all the db
transactions are being done in the web service. The html(aspx) pages call th
e
function needed and then i do formatting on the aspx pages, such as the
datagrids.
The only question i have it the Option Strict. I turned that ON and when I
recompiled the project. I got all kinds of errors such as
Option Strict On Disallows implicit conversions from 'String' to 'Short'
how do i fix that?
"Kevin Spencer" wrote:

> I hate it when my app is done HOO HOO. But what are you going to do? Live
it
> or live with it, as the young lady says...
> ;-)
> Performance. This is one of the reasons why Uncle Chutney says "Big things
> are made up of lots of little things." In a client-server app, this is
> especially true. Small increases or decreases in performance can make a bi
g
> difference when a lot of clients are accessing a web app. Multiply the
> difference in performance by the number of clients, and you can see why.
> There are lots of little things you can do to dramatically increase
> performance. I'll try to hit the big ones.
> 1. In a client-server app, any work done by the client means a big savings
> on the server. The more clients the bigger the savings. Use client-side
> processing and JavaScript whenever possible.
> 2. If your App is written in VB.Net, make sure that Option Strict is turne
d
> ON! Late-binding is anathema to performance.
> 3. Avoid duplication in your app. Don't duplicate values, and don't
> duplicate code. Any time you see the same few lines of code in several
> places, you're looking at a good candidate for a function or Sub. If you
> have created a number of classes that have the same fields, properties,
> and/or methods, you're looking at a good candidate for a base class, and
> derived classes.
> 4. Avoid using the "drag and drop" tools in the toolbox. Some of them are
> quite useful; others are one-size-fits-all memory hogs for beginners, to
> make it easy for them to make something happen without much trouble.
> 5. Close and/or Dispose any objects that use unmanaged resources as quickl
y
> as possible.
> 6. Close database connections ASAP.
> On a similar note, it should be stressed that performance is a factor in
> designing your app. The fastest apps have much more lower-level code in
> them, and are also more proprietary overall. Writing an app that is easily
> extensible may involve a trade-off of performance over code maintainabilit
y.
> Striking the right balance is an art.
> I'm sure I've overlooked several things, but I do believe I've hit on the
> majors in this list. At any rate, I hope it helps.
> --
> HTH,
> Kevin Spencer
> ..Net Developer
> Microsoft MVP
> I get paid good money to
> solve puzzles for a living
> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> news:1DA19F5F-C332-4818-959F-7881D0D3A61A@.microsoft.com...
> is
> Now
> performance.
>
>
Dim x as string = "99"
Dim y as short = CType(x, Short)
OR
Dim y as short = CShort(x)
You'll use a lot of CType with Option Strict On, but it is worth the extra
effort.
Greg
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:8AEAF9A6-319B-4298-AC79-2991C3F89A2A@.microsoft.com...
> All good points. Actually all the db connections are closed and all the db
> transactions are being done in the web service. The html(aspx) pages call
> the
> function needed and then i do formatting on the aspx pages, such as the
> datagrids.
> The only question i have it the Option Strict. I turned that ON and when I
> recompiled the project. I got all kinds of errors such as
> Option Strict On Disallows implicit conversions from 'String' to 'Short'
> how do i fix that?
> "Kevin Spencer" wrote:
>
That worked on the one error.
Now i'm getting Option Strict On disallows Late binding.
I'm doing some formatting of the datagrids based on certain data that is
returned.
How can i fix that issue now?
I need to format the grids based on the data being returned
"Greg Burns" wrote:

> Dim x as string = "99"
> Dim y as short = CType(x, Short)
> OR
> Dim y as short = CShort(x)
> You'll use a lot of CType with Option Strict On, but it is worth the extra
> effort.
> Greg
> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> news:8AEAF9A6-319B-4298-AC79-2991C3F89A2A@.microsoft.com...
>
>
Hi Mike,

> The only question i have it the Option Strict. I turned that ON and when I
> recompiled the project. I got all kinds of errors such as
Awesome! Sounds like you're coming from a VB background. Option Strict
ensures that you use correct data types in your code. The difference between
late and early binding is that Late Binding means that your app explicitly
declares data types, and doesn't mix and match them. This way, the app
already knows at run-time how much memory to allocate for each object. When
late-binding is used, the data type of an object may NOT be known at
run-time, and the Platform has to figure out how much memory to allocate by
calculation, which often involves the use of Reflection. It can slow your
app down quite a bit.
The errors can be fixed by going through your code, and making sure that you
explicitly declare the correct data type for each field, property, or
variable that you are using. Also, avoid the use of the "Object" data type.
Object is the base class for ALL data types, and is therefore a
"late-binding class." So, for example, here is a field and Property declared
with no Data Types:
Private _DayOfW = 1
Public Property DayofW
Get
Return _DayOfW
End Get
Set (ByVal Value)
_DayOfW = Value
End Set
End Property
Using this (Option Strinct OFF), you could assign a TexBox value (always a
string) to DayOfW, and it would compile fine. At run-time, the String
would have to be converted to a number by the Platform.
Instead, you would put (Option Strict ON):
Private _DayOfW As Short = 1
Public Property DayofW As Short
Get
Return _DayOfW
End Get
Set (ByVal Value As Short)
_DayOfW = Value
End Set
End Property
Your code will compile fine, as long as nothing in your code tries to assign
a String to DayOfW. You will get a "Data Type Mismatch" error if you do.
As I'm sure you can see, this also prevents a lot of errors (assigning a
non-numeric string to be used as a Short, for example), as well as informing
the Platform to allocate 16 Bits for _DayOfW.
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:8AEAF9A6-319B-4298-AC79-2991C3F89A2A@.microsoft.com...
> All good points. Actually all the db connections are closed and all the db
> transactions are being done in the web service. The html(aspx) pages call
the
> function needed and then i do formatting on the aspx pages, such as the
> datagrids.
> The only question i have it the Option Strict. I turned that ON and when I
> recompiled the project. I got all kinds of errors such as
> Option Strict On Disallows implicit conversions from 'String' to 'Short'
> how do i fix that?
> "Kevin Spencer" wrote:
>
Live it
things
big
savings
turned
are
quickly
easily
maintainability.
the
noticed
app
seconds.
Please post some code.
Greg
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:24DE9539-DB6D-446D-A5BA-E7B6E4A19960@.microsoft.com...
> That worked on the one error.
> Now i'm getting Option Strict On disallows Late binding.
> I'm doing some formatting of the datagrids based on certain data that is
> returned.
> How can i fix that issue now?
> I need to format the grids based on the data being returned
> "Greg Burns" wrote:
>