473,386 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

VB compiler VS CS compiler

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


Nov 17 '05 #1
20 1281
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...
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

Nov 17 '05 #2
"Dave" <Da*********@hotmail.com> wrote
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


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

Armin
Nov 17 '05 #3
In message <ue**************@TK2MSFTNGP10.phx.gbl>, Dave
<Da*********@hotmail.com> writes
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:


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
Nov 17 '05 #4
Sorry! Seems like there was a problem with my VS
I have reinstalled VS:

Now the results are the same!
CS: 934.375
VB: 945.686

If you like to experiment more, port the CS application to a managed Cpp
application. The cool Cpp comiler seems to calculate the results in compile
time, because the release Cpp.NET application is as fast as lightning!
Try it....

"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
"Dave" <Da*********@hotmail.com> wrote
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


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

Armin


Nov 17 '05 #5
Sorry! Seems like there was a problem with my VS
I have reinstalled VS:

Now the results are the same!
CS: 934.375
VB: 945.686

If you like to experiment more, port the CS application to a managed Cpp
application. The cool Cpp comiler seems to calculate the results in compile
time, because the release Cpp.NET application is as fast as lightning!
Try it....

"Steve Walker" <st***@otolith.demon.co.uk> wrote in message
news:mv**************@otolith.demon.co.uk...
In message <ue**************@TK2MSFTNGP10.phx.gbl>, Dave
<Da*********@hotmail.com> writes
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:


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


Nov 17 '05 #6


Dave wrote:
Sorry! Seems like there was a problem with my VS
I have reinstalled VS:

Now the results are the same!
CS: 934.375
VB: 945.686

If you like to experiment more, port the CS application to a managed Cpp application. The cool Cpp comiler seems to calculate the results in compile time, because the release Cpp.NET application is as fast as lightning! Try it....

"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
"Dave" <Da*********@hotmail.com> wrote
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


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

Armin

A good optimising compiler (I don't know enough to say if the C++.NET
compiler is such a beast) might well optimise your entire test into a
NOP, seeing as it doesn't actually do anything, and can be 'seen' to
not actualy do anything.

(pseudo-code)
A thousand million times do this:
Set a variable to a value, then throw away the variable

--
Larry Lard
Replies to group please

Nov 17 '05 #7
By the way, your C# version was doing many extra iterations since each of
your C# loops was cut short by 1 (this reduction in the outer loop alone
means that your C# version was running 5% fewer iterations).

i.e., "For cnt = 0 to 20" does 1 more iteration than "for (cnt = 0; cnt <
20; cnt++)"

David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter
and the Instant VB C# to VB.NET converter

"Dave" wrote:
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


Nov 17 '05 #8
Oops - I meant " your VB version was doing many extra iterations..."

"David Anton" wrote:
By the way, your C# version was doing many extra iterations since each of
your C# loops was cut short by 1 (this reduction in the outer loop alone
means that your C# version was running 5% fewer iterations).

i.e., "For cnt = 0 to 20" does 1 more iteration than "for (cnt = 0; cnt <
20; cnt++)"

David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter
and the Instant VB C# to VB.NET converter

"Dave" wrote:
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


Nov 17 '05 #9
One minor comment:
I have recently moved from VB.NET to CS.NET to really learn the framework
and see what happens in a real OOP world!
Object oriented programming is not a gift from a language. It starts with a
set of constructs and stretches into the fundamental approach you use when
creating code. VB.Net is an OOP language. So is C#.

In fact, the commercial OO modeling tools and code generators that I am
familiar with will generate code in Java, C++, C#, VB.Net, and Smalltalk. .
All of these languages are Object Oriented. (there are other OO languages
from what I understand, but I don't think many folks are using them).

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Dave" <Da*********@hotmail.com> wrote in message
news:ue**************@TK2MSFTNGP10.phx.gbl...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

Nov 17 '05 #10

"Steve Walker" <st***@otolith.demon.co.uk> wrote in message
news:mv**************@otolith.demon.co.uk...
:
: In message <ue**************@TK2MSFTNGP10.phx.gbl>, Dave
: <Da*********@hotmail.com> writes
: >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:
:
: 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

That was my result as well. I compiled from the command line with the
following commands:

vbc /out:vb.exe tmp.vb
vbc /removeintchecks+ /out:vb.exe tmp.vb

In the former, I saw response times of 1700 ms give or take. With the
checks off, I saw response times in the 1000+/- ms range.
I also tried the CS version with these commands:

csc /out:cs.exe tmp.cs
csc /checked+ /out:cs.exe tmp.cs

The results were similar.
Ralf
Nov 17 '05 #11

"Steve Walker" <st***@otolith.demon.co.uk> wrote in message
news:mv**************@otolith.demon.co.uk...
:
: In message <ue**************@TK2MSFTNGP10.phx.gbl>, Dave
: <Da*********@hotmail.com> writes
: >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:
:
: 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

That was my result as well. I compiled from the command line with the
following commands:

vbc /out:vb.exe tmp.vb
vbc /removeintchecks+ /out:vb.exe tmp.vb

In the former, I saw response times of 1700 ms give or take. With the
checks off, I saw response times in the 1000+/- ms range.
I also tried the CS version with these commands:

csc /out:cs.exe tmp.cs
csc /checked+ /out:cs.exe tmp.cs

The results were similar.
Plz note that I changed the vb Module to a Class (and renamed Sub Main
to Public Shared Sub Main). I don't know if that made a difference, but
I wanted to make the two applications a similar as I could. In addition,
I increased the number of interations in the CS code as the [i = 0; i <
20; i++ ] block runs one fewer passes than [For i = 0 to 20]. That
mattered
While there are important differences between the two languages, I'm of
the opinion that for most situations the choice between which to use is
mostly a matter of personal taste.
Ralf

Nov 17 '05 #12

"Steve Walker" <st***@otolith.demon.co.uk> wrote in message
news:mv**************@otolith.demon.co.uk...
:
: In message <ue**************@TK2MSFTNGP10.phx.gbl>, Dave
: <Da*********@hotmail.com> writes
: >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:
:
: 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

That was my result as well. I compiled from the command line with the
following commands:

vbc /out:vb.exe tmp.vb
vbc /removeintchecks+ /out:vb.exe tmp.vb

In the former, I saw response times of 1700 ms give or take. With the
checks off, I saw response times in the 1000+/- ms range.
I also tried the CS version with these commands:

csc /out:cs.exe tmp.cs
csc /checked+ /out:cs.exe tmp.cs

The results were similar.
Plz note that I changed the vb Module to a Class (and renamed Sub Main
to Public Shared Sub Main). I don't know if that made a difference, but
I wanted to make the two applications a similar as I could. In addition,
I increased the number of interations in the CS code as the [i = 0; i <
20; i++ ] block runs one fewer passes than [For i = 0 to 20]. That
mattered
While there are important differences between the two languages, I'm of
the opinion that for most situations the choice between which to use is
mostly a matter of personal taste.
Ralf

Nov 17 '05 #13
I'm curious, what "real OOP" can you do in C# that can't be done in VB.NET?

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
http://msmvps.com/windsor/
"Dave" <Da*********@hotmail.com> wrote in message
news:ue**************@TK2MSFTNGP10.phx.gbl...
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

Nov 17 '05 #14
Well, you can declare types in an interface in VB.NET, while it generates an
error in CS. Sth like an abstract class in an interface "(Mustinherit" in
VB)....So, i think wheher CS or VB is doing sth wrong here.

"Rob Windsor [MVP]" <ro*****************@gmail.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
I'm curious, what "real OOP" can you do in C# that can't be done in
VB.NET?

Nov 17 '05 #15
Can you give an example?
"Dave" <Da*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
: Well, you can declare types in an interface in VB.NET, while it
: generates an error in CS. Sth like an abstract class in an interface
: "(Mustinherit" in VB)....So, i think wheher CS or VB is doing sth
: wrong here.
:
: "Rob Windsor [MVP]" <ro*****************@gmail.com> wrote in message
: news:%2***************@TK2MSFTNGP15.phx.gbl...
: > I'm curious, what "real OOP" can you do in C# that can't be done in
: > VB.NET?
:
:

Nov 17 '05 #16
"_AnonCoward" <ab*@xyz.com> wrote in message
news:n9********************@twister.southeast.rr.c om...
Can you give an example?


This is what i found in one of the posts to
microsoft.public.dotnet.languages.vb on Friday, April 15, 2005 3:12 PM

The following will compile in VB.NET 2003
-------------------------------------------------------

Public Interface IRenderable
Sub Render()
MustInherit Class Engine
MustOverride Sub TurnOn()
Interface IAutomatic
Sub Start()
End Interface
End Class
End Interface

--------------------------------

Do exactly the same thing in C#.NET 2003; it generates an error. It won't
compile.
Nov 17 '05 #17
how does this make C# a real OO language where VB.Net is not?

I see a minor language difference. I don't see something that prevents you
from describing VB as an OO language.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Dave" <Da*********@hotmail.com> wrote in message
news:uN***************@TK2MSFTNGP12.phx.gbl...
"_AnonCoward" <ab*@xyz.com> wrote in message
news:n9********************@twister.southeast.rr.c om...
Can you give an example?


This is what i found in one of the posts to
microsoft.public.dotnet.languages.vb on Friday, April 15, 2005 3:12 PM

The following will compile in VB.NET 2003
-------------------------------------------------------

Public Interface IRenderable
Sub Render()
MustInherit Class Engine
MustOverride Sub TurnOn()
Interface IAutomatic
Sub Start()
End Interface
End Class
End Interface

--------------------------------

Do exactly the same thing in C#.NET 2003; it generates an error. It won't
compile.

Nov 17 '05 #18
Dave,

I hope that I don't kick to many people with this message. In my opinion is
OO not direct programming related.

When there was 100 years ago a house build in my country, than most parts
were created on the place where the building would come.

Now they are designed first where as much elements from prefab classes are
used.

For me is that the essence of OOP. That there is syntax around it tells
nothing. The same as with building houses are (and should) the methods that
creates the classes every time be better and better.

Just my thought,

Cor
Nov 17 '05 #19

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Ob*************@TK2MSFTNGP12.phx.gbl...
Dave,

I hope that I don't kick to many people with this message. In my opinion
is OO not direct programming related.

When there was 100 years ago a house build in my country, than most parts
were created on the place where the building would come.

Now they are designed first where as much elements from prefab classes are
used.

For me is that the essence of OOP. That there is syntax around it tells
nothing. The same as with building houses are (and should) the methods
that creates the classes every time be better and better.

Just my thought,

Cor


You are right probably.... it might be a matter of personal taste. But
believe me, coming from the world of VB6 into VB.NET was not only a "shock",
but also the oop concepts were too odd to swallow. I couldn't really get
on it...There were all those powerful object facilities in VB.NET...
i just couldn't exploit them...maybe because of the background-VB syntax i
had
in my thinking patterns.
The change to C# for me was a way to pass over that obstacle. Everything is
where it has to be, the language is as brief and as original as possible...
and it is now that i am realizing what OOP really is and what goes on at the
heart of the
framework.

As i said...just my thought of course.

Nov 17 '05 #20
> for (cnt = 0; cnt < 20; cnt++)

this loop runs from 0 to 19, 20 itterations.
For cnt = 0 To 20


This loop runs from 0 to 20, 21 itterations.

All of your loops have this flaw, something to watch out for as in the case
of your test, the problem in each loop level tends to build up exponentially,
in this case you would be running about 100*10000000 extra loops in your VB
code, obviously not good for comparisons (and flat out evil if you are trying
to exactly reproduce code).

For cnt = 0 to 20 is equivalent to for (int cnt=0; cnt<=20; cnt++)

Moving from a 1 based universe to a zero based universe can be annoying
(every time I move from delphi strings to c strings it gives me a headache),
but you gotta watch those details.

- Clinton R. Johnson
Nov 17 '05 #21

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bengt Richter | last post by:
I think for some purposes it might be handy to have and exact value representation in the compiler parse tree, without having to use strings as carrier. I.e., >>> from exactdec import ED >>>...
3
by: Andrey Batyuck | last post by:
Greetings. Do you know any compiler compiler that can give output in C++? I would like to implement run-time scripting system in my system, and i am looking for fully object-oriented compiler...
1
by: miles.wrigley | last post by:
We need a C/C++ compiler: - Compiler will be used to create functions and OBJs/LIBs (C++ code with C language wrapper) that will be linked and called from an embedded application. - Preferred...
15
by: Anton Gavrilov | last post by:
Hi all, I seek your advice on where to start if I want to write a compiler for a toy C-like language I invented (or, rather, am in the process of inventing). Yes, yes, I know I'm crazy and the...
7
by: ajm | last post by:
Hi All, given an object file is there any way (or tool) to determine which compiler created it ? tia, A.
19
by: petantik | last post by:
Where can I find a good resource, on the web, that will give me a good comprehensive idea of how to write a compiler in C for C or maybe another language. http://petantik.blogsome.com - A...
8
by: Pawel | last post by:
Hi. Hello, i want doing simple compiler in C# (.NET). I have lexer and parse file. What kind of tools should I use? And what to do?? Thanks! pawel
19
by: rnbrady | last post by:
Hi folks New around here. This post may be a duplicate, I think I bungled the previous one. I've recently started out with XML and XSL and I'm very impressed with both. My use is non-web in...
5
by: mark_galeck_spam_magnet | last post by:
Hi, why does complain name 'compileFile' not defined. But works. Why? (I did read the tutorial, it seems to say "import module" should work. Thank you, Mark
41
by: Miroslaw Makowiecki | last post by:
Where can I download Comeau compiler as a trial version? Thanks in advice.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.