VB编译VS CS编译器 [英] VB compiler VS CS compiler

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

问题描述

我最近从VB.NET迁移到CS.NET,真正学习了框架

,看看真正的OOP世界会发生什么!我对这一举动感到非常高兴,因为我花了很短的时间才花了很多时间来利用CS作为我的新语言

选择,只留下一些VB.NET UI创建。这就是说,我应该建议,尽管有关于这两种语言(这也意味着他们的托管应用程序)的平等的所有说法,我已经看到了

CS应用程序的性能比他们的VB.NET计数器部件好得多。

这是一个非常奇怪的注意事项,因为在$ / $ $ b $中观察到差异b性能是纯粹的算术计算,必须编译成同一个IL并使用相同的JITting机器JITted
。我的实验

包含以下VB和CS控制台应用程序的解决方案:


CS项目 - 控制台应用程序:


/ ----------------------------------------------- -----------


使用系统;

class Class1

{

static void Main()

{

//做三次实验

double total = 0;

int cnt = 0;


for(cnt = 0; cnt< 20; cnt ++)

{

DateTime t1 = DateTime.Now;


//关键部分:

for(int i = 0; i< 10000000; i ++)

{

for(int j = 0; j< 100; j ++)

{

long y;

y = j;

}

}

///////////////// ////////////

DateTime t2 = DateTime.Now;

TimeSpan t = t2 - t1;

Console.Write(操作采取:{0} \ n,t.TotalMilliseconds);

total + = t.TotalMilliseconds;

}

Console.WriteLine(" \\\
- \ n平均时间为:{0} \ n",total / cnt);

Console.ReadLine();

}

}

// ------------ -----------------------------

CS属性:

发布模式

优化+

不检查算术溢出


关键操作所需的平均时间:2777.34375毫秒


************************************* ****

VB项目 - 控制台应用


''------------------- ---------------------------

Option Strict On

Option Explicit On


模块模块1


Sub Main()


Dim total As Double = 0

Dim cnt As Integer = 0


对于cnt = 0到20

Dim t1 As DateTime = DateTime.Now


''关键部分

对于i作为整数= 0到10000000

对于j作为整数= 0到100

Dim y As Long

y = j

下一页

下一页

''''

Dim t2 As DateTime = DateTime.Now

Dim t As TimeSpan = t2.op_Subtraction(t2,t1)


控制台.WriteLine(" ope口粮花了{0}",t.TotalMilliseconds)

总+ + t.TotalMilliseconds

下一页


Console.WriteLine (vbCrLf& 平均时间是:{0},总计/ cnt)

Console.ReadLine()

结束子


结束模块

''--------------------------

VB项目物业:


发布模式

优化+

不检查算术溢出


关键操作的平均时间:3723.9583。毫秒


**********************************

这些测试是在以下机器上完成的:

CPU:Intel Celeron 2.40 GHz

256 MB RAM


..NET Framework 1.1

VS 2003


无病毒扫描运行

请告诉我,如果我错了或某事。否则请告诉我真正的

导致这个。


提前致谢


I have recently moved from VB.NET to CS.NET to really learn the framework
and see what happens in a real OOP world! I am too happy with this move,
since it took me a very short time, to exploit CS as my new language of
choice, leaving VB.NET only for some UI creation. This said, i should
recommend that in spite of all words out there about the equality of these
two languages (which also means their managed applications), i have seen
much better performance in CS application than their VB.NET counter parts.
This is a very strange thing to note, since the differences observed in
performance were in pure arithmetic calculations, which had to be compiled
to the same IL and JITted with the same JITting machine. My Experiment
included a solution with the following VB and CS console applications:

CS project - Console Application:

/----------------------------------------------------------

using System;
class Class1
{
static void Main()
{
//Do the experiment three times
double total =0;
int cnt = 0;

for (cnt = 0; cnt < 20; cnt++)
{
DateTime t1 = DateTime.Now;

//The critical section:
for(int i=0; i<10000000; i++)
{
for(int j=0; j<100; j++)
{
long y ;
y = j;
}
}
/////////////////////////////
DateTime t2 = DateTime.Now;
TimeSpan t = t2 - t1;
Console.Write("The operation took: {0}\n", t.TotalMilliseconds);
total += t.TotalMilliseconds;
}
Console.WriteLine("\n--\nThe average time was: {0}\n", total / cnt);
Console.ReadLine();
}
}
//-----------------------------------------
CS properties:
Release mode
Optimize+
No check for arithmetic overflows

Average time took for critical operation: "2777.34375" milliseconds

*****************************************
VB Project - Console Application

''----------------------------------------------
Option Strict On
Option Explicit On

Module Module1

Sub Main()

Dim total As Double = 0
Dim cnt As Integer = 0

For cnt = 0 To 20

Dim t1 As DateTime = DateTime.Now

'' The critical section
For i As Integer = 0 To 10000000
For j As Integer = 0 To 100
Dim y As Long
y = j
Next
Next
''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim t2 As DateTime = DateTime.Now
Dim t As TimeSpan = t2.op_Subtraction(t2, t1)

Console.WriteLine("The operation took {0}", t.TotalMilliseconds)
total += t.TotalMilliseconds
Next

Console.WriteLine(vbCrLf & "The average time was: {0}", total / cnt)
Console.ReadLine()
End Sub

End Module
''--------------------------
VB project properties:

Release Mode
Optimize+
No check for arithmetic overflows

Average time took for critical operation: "3723.9583" milliseconds

**********************************

These tests were done on the following machine:
CPU: Intel Celeron 2.40 GHz
256 MB of RAM

..NET Framework 1.1
VS 2003
Win XP Pro SP2 with latest updates

No virus scanning running
Please tell me if i am wrong or sth. Otherwise please inform me what really
causes this.

Thanks in advance


推荐答案

查看循环以确保您运行测试的次数相同

次...


-


" Dave" <沓********* @ hotmail.com> écritdansle message de

news:ue ************** @ TK2MSFTNGP10.phx.gbl ...
Check out the loops to make sure you are running the test the same number of
times...

--

"Dave" <Da*********@hotmail.com> a écrit dans le message de
news:ue**************@TK2MSFTNGP10.phx.gbl...
我有最近从VB.NET迁移到CS.NET,真正学习框架
,看看真正的OOP世界会发生什么!我对这一举动感到非常高兴,因为我花了很短的时间,将CS作为我选择的新语言,只留下VB.NET用于创建UI。这就是说,我应该建议尽管有关于这两种语言(这也意味着他们的托管应用程序)的平等的所有说法,我已经看到在CS中表现更好应用程序比他们的VB.NET计数器部分。
这是一个非常奇怪的事情要注意,因为在性能上观察到的差异是在纯算术计算中,必须编译成相同的IL和JITted使用相同的JITting机器。我的实验
包含以下VB和CS控制台应用程序的解决方案:

CS项目 - 控制台应用程序:

/ --------- -------------------------------------------------

使用System;
class Class1
{
static void Main()
//
//做实验三次
double total = 0;
int cnt = 0;

for(cnt = 0; cnt< 20; cnt ++)
{/ / DateTime t1 = DateTime.Now ;

//关键部分:
for(int i = 0; i< 10000000; i ++)
{
for(int j = 0; j< 100; j ++)
{
长y;
y = j;
}
}
//////////// /////////////////
DateTime t2 = DateTime.Now;
TimeSpan t = t2 - t1;
Console.Write(&操作采取:{0} \ n",t.TotalMilliseconds);
total + = t.TotalMilliseconds;
}
Console.WriteLine(" \\\
- \\\
The平均时间是:{0} \ n",total / cnt);
Console.ReadLine();
}
}

// ---------- -------------------------------
CS属性:
发布模式
优化+ <不检查算术溢出

关键操作的平均时间:2777.34375毫秒

*****************************************

VB项目 - 控制台应用程序

''--------------------------- -------------------
Option Strict On
明确选项

模块模块1
Sub Main()

Dim total As Double = 0
Dim cnt As Integer = 0

对于cnt = 0到20
Dim t1 As DateTime = DateTime.Now

''关键部分
对于我作为整数= 0到10000000
对于j作为整数= 0到100
昏昏欲睡
y = j
下一页
''''''''''''''''''''''''''' '='''''/ / / / / / / / / / / / / / / / / / / / / / / / / = t2.op_Subtraction(t2,t1)

Console.WriteLine(操作花了{0},
t.TotalMilliseconds)总计+ = t.TotalMilliseconds
下一页

Console.WriteLine(vbCrLf& 平均时间为:{0},总计/
cnt)Console.ReadLine()
End Sub

结束模块

''--------------------------
VB项目属性:

发布模式
优化+
不检查算术溢出

关键操作的平均时间:3723.9583毫秒

**********************************
这些测试在以下机器上完成:
CPU:Intel Celeron 2.40 GHz
256 MB RAM

.NET Framework 1.1
VS 2003
最新更新的Win XP Pro SP2

没有病毒扫描运行

请告诉我,如果我错了或某事。否则请告诉我
究竟是什么造成的。

提前致谢
I have recently moved from VB.NET to CS.NET to really learn the framework
and see what happens in a real OOP world! I am too happy with this move,
since it took me a very short time, to exploit CS as my new language of
choice, leaving VB.NET only for some UI creation. This said, i should
recommend that in spite of all words out there about the equality of these
two languages (which also means their managed applications), i have seen
much better performance in CS application than their VB.NET counter parts.
This is a very strange thing to note, since the differences observed in
performance were in pure arithmetic calculations, which had to be compiled
to the same IL and JITted with the same JITting machine. My Experiment
included a solution with the following VB and CS console applications:

CS project - Console Application:

/----------------------------------------------------------

using System;
class Class1
{
static void Main()
{
//Do the experiment three times
double total =0;
int cnt = 0;

for (cnt = 0; cnt < 20; cnt++)
{
DateTime t1 = DateTime.Now;

//The critical section:
for(int i=0; i<10000000; i++)
{
for(int j=0; j<100; j++)
{
long y ;
y = j;
}
}
/////////////////////////////
DateTime t2 = DateTime.Now;
TimeSpan t = t2 - t1;
Console.Write("The operation took: {0}\n", t.TotalMilliseconds);
total += t.TotalMilliseconds;
}
Console.WriteLine("\n--\nThe average time was: {0}\n", total / cnt);
Console.ReadLine();
}
}
//-----------------------------------------
CS properties:
Release mode
Optimize+
No check for arithmetic overflows

Average time took for critical operation: "2777.34375" milliseconds

*****************************************
VB Project - Console Application

''----------------------------------------------
Option Strict On
Option Explicit On

Module Module1

Sub Main()

Dim total As Double = 0
Dim cnt As Integer = 0

For cnt = 0 To 20

Dim t1 As DateTime = DateTime.Now

'' The critical section
For i As Integer = 0 To 10000000
For j As Integer = 0 To 100
Dim y As Long
y = j
Next
Next
''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim t2 As DateTime = DateTime.Now
Dim t As TimeSpan = t2.op_Subtraction(t2, t1)

Console.WriteLine("The operation took {0}", t.TotalMilliseconds) total += t.TotalMilliseconds
Next

Console.WriteLine(vbCrLf & "The average time was: {0}", total / cnt) Console.ReadLine()
End Sub

End Module
''--------------------------
VB project properties:

Release Mode
Optimize+
No check for arithmetic overflows

Average time took for critical operation: "3723.9583" milliseconds

**********************************

These tests were done on the following machine:
CPU: Intel Celeron 2.40 GHz
256 MB of RAM

.NET Framework 1.1
VS 2003
Win XP Pro SP2 with latest updates

No virus scanning running
Please tell me if i am wrong or sth. Otherwise please inform me what really causes this.

Thanks in advance



" Dave" ; <沓********* @ hotmail.com>写了
"Dave" <Da*********@hotmail.com> wrote
CS项目 - 控制台应用程序:
关键操作的平均时间:2777.34375毫秒


VB项目 - 控制台应用程序
关键操作的平均时间:3723.9583毫秒



使用相同的代码和设置:


C#版本:1605

VB.Net :1619

(=等于)

CPU:Intel Celeron 2.40 GHz
CS project - Console Application:
Average time took for critical operation: "2777.34375" milliseconds
VB Project - Console Application
Average time took for critical operation: "3723.9583" milliseconds

With same code and settings:

C# version: 1605
VB.Net: 1619

(= equal)
CPU: Intel Celeron 2.40 GHz




很高兴看到我的结果来自1,4GHz AMD(XP1600 +)。

您选择开始无需调试吗?来自调试菜单?


Armin



Glad to see that my results come from an 1,4GHz AMD (XP1600+) here.
Did you choose "Start withouth debugging" from debug menu?

Armin


在消息< ue *************中*@TK2MSFTNGP10.phx.gbl> ;,戴夫

< Da ********* @ hotmail.com>写道
In message <ue**************@TK2MSFTNGP10.phx.gbl>, Dave
<Da*********@hotmail.com> writes
我最近从VB.NET转到CS.NET,真正学习了这个框架,看看真正的OOP世界会发生什么!我对这一举动感到非常高兴,因为我花了很短的时间,将CS作为我选择的新语言,只留下VB.NET用于创建UI。这就是说,我应该建议尽管有关于这两种语言(这也意味着他们的托管应用程序)的平等的所有说法,我已经看到在CS中表现更好应用程序比他们的VB.NET计数器部分。
这是一个非常奇怪的事情要注意,因为在性能上观察到的差异是在纯算术计算中,必须编译成相同的IL和JITted使用相同的JITting机器。我的实验
包括以下VB和CS控制台应用程序的解决方案:
I have recently moved from VB.NET to CS.NET to really learn the framework
and see what happens in a real OOP world! I am too happy with this move,
since it took me a very short time, to exploit CS as my new language of
choice, leaving VB.NET only for some UI creation. This said, i should
recommend that in spite of all words out there about the equality of these
two languages (which also means their managed applications), i have seen
much better performance in CS application than their VB.NET counter parts.
This is a very strange thing to note, since the differences observed in
performance were in pure arithmetic calculations, which had to be compiled
to the same IL and JITted with the same JITting machine. My Experiment
included a solution with the following VB and CS console applications:




我得到:


C# :1090 ms

VB:1600 ms(带溢出检查)

VB:1100 ms(无溢出检查)


Are你确定你有删除整数溢出检查盒子打勾?


-

Steve Walker



I get:

C#: 1090 ms
VB: 1600 ms (with overflow checking)
VB: 1100 ms (without overflow checking)

Are you sure you had the "Remove integer overflow checks" box ticked?

--
Steve Walker


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

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