|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB Code questionVB.Net using Visual Studio .Net 2003. That said I have been given the task of making it run "faster". I am a C# programmer and I know there are statistics out there for different ways to do the same thing an which is faster. Ex. Casting variables in C# I know the (int)MyStringVariable; is slower than int.Parse(MyStringVariable); I was wondering if there were such stats for VB.Net like using the older VB6 type methods of InStr and Mid versus using MyStringVariable.Contains() or MyStringVariable.SubString()? Does anyone have a reference for this and maybe how I can improve performance on an app that was written by a VB6 developer who just learned VB.Net and applied a lot of VB6 coding practices? Note: I do not wish to cause a battle between C# and VB.Net or VB6 developers here. Just looking for info. <rasta***@gmail.com> wrote in message
Show quoteHide quote news:1153929984.941062.19180@i3g2000cwc.googlegroups.com... I could have sworn that you couldn't cast a string variable to an int in >I am working with a Compact Framework project that was written in > VB.Net using Visual Studio .Net 2003. That said I have been given the > task of making it run "faster". I am a C# programmer and I know there > are statistics out there for different ways to do the same thing an > which is faster. > > Ex. Casting variables in C# I know the (int)MyStringVariable; is slower > than int.Parse(MyStringVariable); > > I was wondering if there were such stats for VB.Net like using the > older VB6 type methods of InStr and Mid versus using > MyStringVariable.Contains() or MyStringVariable.SubString()? > > Does anyone have a reference for this and maybe how I can improve > performance on an app that was written by a VB6 developer who just > learned VB.Net and applied a lot of VB6 coding practices? > > Note: I do not wish to cause a battle between C# and VB.Net or VB6 > developers here. Just looking for info. > C#....I guess I'll need to try it. In any case, simple casting won't really speed up an application much. And regardless of language used, it's really how the app was designed in the first place. Refactoring code would be a good start. Take a look at some of the methods, see if you could logically speed them up by rewriting them altogether. Check loops to make sure the amount of iterations is minimized. Check logic to make sure they are only performing complex calculations if and when they are needed. There are a lot of things too look for in order to speed up applications. Primarily though, the major slow-down that I've pulled my hair out over is other people's loops. For example, a loop that is set up to find a record. If they find the record they are looking for, they set a variable that's declared outside the loop...AND KEEP LOOPING! Why? I dunno, but breaking the loop right then could save LOTS of time ... just one example :) Anywho, hth. Mythran It seems in my post I just made that I used the term Refractor (If i
remember correctly) out of context. Basically, I mean take a look at the overall picture of the code you are looking at and see if there's anything sticking out that doesn't belong. Then take a look at the code piece by piece...in manageable chunks... :) Guess I'm just making up words as I go along (or definitions to existing Mythranwords)
Show quote
Hide quote
> I am working with a Compact Framework project that was written in I have some performance comparisons of CInt, Integer.Parse, Integer.TryParse, > VB.Net using Visual Studio .Net 2003. That said I have been given the > task of making it run "faster". I am a C# programmer and I know there > are statistics out there for different ways to do the same thing an > which is faster. > > Ex. Casting variables in C# I know the (int)MyStringVariable; is > slower than int.Parse(MyStringVariable); > > I was wondering if there were such stats for VB.Net like using the > older VB6 type methods of InStr and Mid versus using > MyStringVariable.Contains() or MyStringVariable.SubString()? > > Does anyone have a reference for this and maybe how I can improve > performance on an app that was written by a VB6 developer who just > learned VB.Net and applied a lot of VB6 coding practices? etc at http://devauthority.com/blogs/jwooley/archive/2006/02/15/747.aspx. In general, it is often best to try makeing performance comparisons yourself. Also, there is a point in which you need to balance performance and maintainability. Sometimes saving 2 ticks isn't worth spending 2 days each time you need to maintain the code, but in other times it is. Learning to balance these needs is the art of programming. Jim Wooley http://devauthority.com/blogs/jwooley/default.aspx rasta***@gmail.com wrote:
Show quoteHide quote >I am working with a Compact Framework project that was written in The main thing I would look at is object instantiation - it is a >VB.Net using Visual Studio .Net 2003. That said I have been given the >task of making it run "faster". I am a C# programmer and I know there >are statistics out there for different ways to do the same thing an >which is faster. > >Ex. Casting variables in C# I know the (int)MyStringVariable; is slower >than int.Parse(MyStringVariable); > >I was wondering if there were such stats for VB.Net like using the >older VB6 type methods of InStr and Mid versus using >MyStringVariable.Contains() or MyStringVariable.SubString()? > >Does anyone have a reference for this and maybe how I can improve >performance on an app that was written by a VB6 developer who just >learned VB.Net and applied a lot of VB6 coding practices? > >Note: I do not wish to cause a battle between C# and VB.Net or VB6 >developers here. Just looking for info. > > > resource killer. Better to have an object hang around for a while longer than to keep making a new one. That's my 2 cents. T Rasta,
It is forever nice that people are searching for performance in looping, casting, and all those things that takes parts of nanoseconds. Have a look at how you are using your screen or other external devices. The repaint of a little part of your screen takes in every system more performance than millions times those things as I wrote above. Have you by instance a fancy icon running, have than a look at that, maybe it is eating up most of your processor time. Just my first thought, Cor <rasta***@gmail.com> schreef in bericht Show quoteHide quote news:1153929984.941062.19180@i3g2000cwc.googlegroups.com... >I am working with a Compact Framework project that was written in > VB.Net using Visual Studio .Net 2003. That said I have been given the > task of making it run "faster". I am a C# programmer and I know there > are statistics out there for different ways to do the same thing an > which is faster. > > Ex. Casting variables in C# I know the (int)MyStringVariable; is slower > than int.Parse(MyStringVariable); > > I was wondering if there were such stats for VB.Net like using the > older VB6 type methods of InStr and Mid versus using > MyStringVariable.Contains() or MyStringVariable.SubString()? > > Does anyone have a reference for this and maybe how I can improve > performance on an app that was written by a VB6 developer who just > learned VB.Net and applied a lot of VB6 coding practices? > > Note: I do not wish to cause a battle between C# and VB.Net or VB6 > developers here. Just looking for info. > IMO the first step would be to try to find out where the time budget is
mostly spent. IMO it's unlikely that a cast or something similar will produce a visible difference. If you are able to define the area where the time is mostly spent, you'll be able to give a closer look for possible improvments (caching, avoiding uneeded work, better algo or whatever else). -- Show quoteHide quotePatrice <rasta***@gmail.com> a écrit dans le message de news: 1153929984.941062.19***@i3g2000cwc.googlegroups.com... >I am working with a Compact Framework project that was written in > VB.Net using Visual Studio .Net 2003. That said I have been given the > task of making it run "faster". I am a C# programmer and I know there > are statistics out there for different ways to do the same thing an > which is faster. > > Ex. Casting variables in C# I know the (int)MyStringVariable; is slower > than int.Parse(MyStringVariable); > > I was wondering if there were such stats for VB.Net like using the > older VB6 type methods of InStr and Mid versus using > MyStringVariable.Contains() or MyStringVariable.SubString()? > > Does anyone have a reference for this and maybe how I can improve > performance on an app that was written by a VB6 developer who just > learned VB.Net and applied a lot of VB6 coding practices? > > Note: I do not wish to cause a battle between C# and VB.Net or VB6 > developers here. Just looking for info. >
Show quote
Hide quote
> I am working with a Compact Framework project that was written in I went through the vb6 to vb.net and faced the same issue. The > VB.Net using Visual Studio .Net 2003. That said I have been given the > task of making it run "faster". I am a C# programmer and I know there > are statistics out there for different ways to do the same thing an > which is faster. > > Ex. Casting variables in C# I know the (int)MyStringVariable; is slower > than int.Parse(MyStringVariable); > > I was wondering if there were such stats for VB.Net like using the > older VB6 type methods of InStr and Mid versus using > MyStringVariable.Contains() or MyStringVariable.SubString()? > > Does anyone have a reference for this and maybe how I can improve > performance on an app that was written by a VB6 developer who just > learned VB.Net and applied a lot of VB6 coding practices? documentation contains some guidelines re performance, and in general, you should follow them. When converting code, I did that except where it meant a lot of work for little gain. I also used the profiler nprof (it is freeware, others are available). It exposes bottlenecks at the function level (not statement level), and that is all you need for vb.net. It exposed a few things I was doing foolishly in ..net, eg: 1. Making long strings by concatenating many small pieces using the given string operations. Use stringbuilder instead. 2. Using Mid$ assignments in loops against big strings. This a vb6 natural that does not perform well in .net. It is similar to #1 above. 3. I was using Debug.Assert(xxx,yyy) in a loop where yyy was an expensive function call. I found nprof to be very productive in improving performance. I would run my program under nprof's control, and examine the tree-like output to find where I spent the most amount of time. In vb, that usually reduced to a piece of the vb library, eg mid$ operations. You can look at the code that calls the offending function and recode a small area. For me, the biggest offender was sloppy string handling in loops. Yes string handling in .net is really terrible!!
Whenever meaningful use always stringbuilder. Also the try/catch structure, if exceptions really occurs, is one of the worst things one can put in a loop: a real suicide... :) -t AMercer ha scritto: Show quoteHide quote > > I am working with a Compact Framework project that was written in > > VB.Net using Visual Studio .Net 2003. That said I have been given the > > task of making it run "faster". I am a C# programmer and I know there > > are statistics out there for different ways to do the same thing an > > which is faster. > > > > Ex. Casting variables in C# I know the (int)MyStringVariable; is slower > > than int.Parse(MyStringVariable); > > > > I was wondering if there were such stats for VB.Net like using the > > older VB6 type methods of InStr and Mid versus using > > MyStringVariable.Contains() or MyStringVariable.SubString()? > > > > Does anyone have a reference for this and maybe how I can improve > > performance on an app that was written by a VB6 developer who just > > learned VB.Net and applied a lot of VB6 coding practices? > > I went through the vb6 to vb.net and faced the same issue. The > documentation contains some guidelines re performance, and in general, you > should follow them. When converting code, I did that except where it meant a > lot of work for little gain. > > I also used the profiler nprof (it is freeware, others are available). It > exposes bottlenecks at the function level (not statement level), and that is > all you need for vb.net. It exposed a few things I was doing foolishly in > .net, eg: > > 1. Making long strings by concatenating many small pieces using the given > string operations. Use stringbuilder instead. > > 2. Using Mid$ assignments in loops against big strings. This a vb6 natural > that does not perform well in .net. It is similar to #1 above. > > 3. I was using Debug.Assert(xxx,yyy) in a loop where yyy was an expensive > function call. > > I found nprof to be very productive in improving performance. I would run > my program under nprof's control, and examine the tree-like output to find > where I spent the most amount of time. In vb, that usually reduced to a > piece of the vb library, eg mid$ operations. You can look at the code that > calls the offending function and recode a small area. For me, the biggest > offender was sloppy string handling in loops. rasta***@gmail.com wrote:
> I am working with a Compact Framework project that was written in I had an app written for the CF for .Net 1.1. When I recompiled the> VB.Net using Visual Studio .Net 2003. That said I have been given the app using .Net 2.0 CF, it ran *much* faster. One operation that normally took about 30 - 40 seconds, now only takes about 5. So in addition to the other replies, if you can rebuild it for CF 2.0, then that should help as well. rasta***@gmail.com wrote:
> I am working with a Compact Framework project that was written in The best statistics are those derived from your application itself. Can > VB.Net using Visual Studio .Net 2003. That said I have been given the > task of making it run "faster". I am a C# programmer and I know there > are statistics out there for different ways to do the same thing an > which is faster. you say which line of code is taking the most processor time? If you don't know you should find out. > Ex. Casting variables in C# I know the (int)MyStringVariable; is slower Considerably slower, since the former doesn't actually compile.> than int.Parse(MyStringVariable); -- Larry Lard larryl***@googlemail.com The address is real, but unread - please reply to the group For VB and C# questions - tell us which version
At least one object must implement IComparable
How to create multiple threads? What is an assembly? Compiling VB (.NET) files located in different directories Parsing Files with Regular Expressions Anyone can help me?£¬How to Convert C# to VB.NET, about Flood Fill Can WinCE & Pocket PC support the "AsyncCallback"? How to launch program from CD after vb deployment installed Datagridview - Move Focus to a Particular Cell Updating MS Access tables |
|||||||||||||||||||||||