VB代码问题 [英] VB Code question

查看:70
本文介绍了VB代码问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio .Net 2003在

VB.Net中编写的Compact Framework项目。这就是说我已经获得了

任务让它更快地运行。我是一个C#程序员,我知道

是统计数据,不同的方法可以做同样的事情

更快。


Ex。在C#中转换变量我知道(int)MyStringVariable;比int.Parse(MyStringVariable)更慢

;


我想知道VB.Net是否有这样的统计数据,比如使用

旧的VB6类型的InStr和Mid与使用的方法

MyStringVariable.Contains()或MyStringVariable.SubString()?


有没有人有参考对于这个,也许我可以如何改进由VB6开发人员编写的应用程序的性能,这个开发人员只是学习了VB.Net并应用了很多VB6编码实践?


注意:我不希望在C#和VB.Net或VB6之间引起争执。
开发者在这里。只是寻找信息。

解决方案



< ra ****** @ gmail。消息中写道

news:11 ********************* @ i3g2000cwc.googlegrou ps.com ...
< blockquote class =post_quotes>
>我正在使用Visual Studio .Net 2003在

VB.Net中编写的Compact Framework项目。这就是说我得到了

使其运行更快的任务。我是一个C#程序员,我知道

是统计数据,不同的方法可以做同样的事情

更快。


Ex。在C#中转换变量我知道(int)MyStringVariable;比int.Parse(MyStringVariable)更慢

;


我想知道VB.Net是否有这样的统计数据,比如使用

旧的VB6类型的InStr和Mid与使用的方法

MyStringVariable.Contains()或MyStringVariable.SubString()?


有没有人有参考对于这个,也许我可以如何改进由VB6开发人员编写的应用程序的性能,这个开发人员只是学习了VB.Net并应用了很多VB6编码实践?


注意:我不希望在C#和VB.Net或VB6之间引起争执。
开发者在这里。只是寻找信息。



我本可以发誓,你不能把一个字符串变量转换成一个int在

C#.. ..我想我需要尝试一下。在任何情况下,简单的铸造都不会真正加快应用程序的速度。而且无论使用何种语言,应用程序的首次设计都是如此。

。重构代码将是一个好的开始。看看一些方法,看看你是否可以逻辑地通过重写它们来加速它们。检查循环以确保

迭代量最小化。检查逻辑以确保它们只是在需要时执行复杂的计算。


有很多东西也是为了找到它们加快应用程序。

首先,我把头发拉过来的主要减速是

其他人的循环。例如,设置一个循环来查找记录。

如果他们找到了他们正在寻找的记录,他们会设置一个变量'

在外面声明循环...并保持循环!为什么?我不知道,但是打破

循环就可以节省很多时间......只是一个例子:)


Anywho,hth。


Mythran


在我的帖子中我似乎只是使用了术语Refractor(如果我

)正确地)脱离背景。基本上,我的意思是看看你正在看的代码的整个图片,看看是否有什么东西

突然出现的不属于。然后用可管理的块来看看代码片段

piece ...


:)猜猜我只是在编造单词当我一起去(或定义现有的

字)


Mythran


我在工作使用Visual Studio .Net 2003在


VB.Net中编写的Compact Framework项目。这就是说我得到了

让它更快地运行的任务。我是一个C#程序员,我知道

是统计数据,不同的方法可以做同样的事情

更快。


Ex。在C#中转换变量我知道(int)MyStringVariable;是
慢于int.Parse(MyStringVariable);


我想知道VB.Net是否有这样的统计数据,比如使用

旧的VB6类型的InStr和Mid与使用的方法

MyStringVariable.Contains()或MyStringVariable.SubString()?


有没有人有参考对于这个,也许我可以如何改进由VB6开发人员编写的应用程序的性能,这个开发人员只是学习了VB.Net并应用了很多VB6编码实践?



我对CInt,Integer.Parse,Integer.TryParse,

等进行了性能比较
http://devauthority.com/blogs/jwoole ... 2月15日/ 747.aspx 。一般来说,

通常最好自己尝试进行性能比较。此外,

是您需要平衡性能和可维护性的点。

有时保存2个刻度并不值得每次需要花费2天

维护代码,但在其他时候它是。学会平衡这些需求

是编程的艺术。


Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx


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.

解决方案


<ra******@gmail.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.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.

I could have sworn that you couldn''t cast a string variable to an int in
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
words)

Mythran


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 have some performance comparisons of CInt, Integer.Parse, Integer.TryParse,
etc at
http://devauthority.com/blogs/jwoole...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


这篇关于VB代码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆