Thursday, March 29, 2012

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.
>> >>> >>> >>
>> >>
>> >>
>>
>>
>

0 comments:

Post a Comment