D
Dave
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
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