General discussion
-
Topic
-
VB Net is Faster Than C#?
LockedOur software has several modules with heavy calculation written by VB6. Before migrate to dot net, we would like to find out which is the better language to adapt to. Since most developers prefer C#, the test itself is symbolic. To avoid any side-effect, the test includes pure calculations only. There are no arrays, collections, or strings. The test is conducted using 3 languages, VB6, C# & VBNet. On the main forms of each one, a text box keeps the times of iterations (100000000), other textbox to show the elapsed time, and a command button to execute. I did not use machine frequency or ticker to count time. Here is the VB code written in the click event of the command button.
Dim i As Long
Dim iDiff As Integer iter = CLng(txtIterations.Text)dA = 10.12
dB = 3.5678
dC = 12.845
DTStart = NowFor i = 1 To iter
dR = dA + dB – dC
dR = dA * dB / dC
dR = dA – dB + dC
dR = dA / dB * dCNextDTEnd = Now
iDiff = DateDiff(“s”, DTStart, DTEnd)txtTimeUsed = iDiff
It is quite easy to duplicate the codes in C# & VBNet where dR, dA, dB, & dC are double with module scope. The variables are declared under samescope in each language.
The results are surprising for this specific test.
C# and VB6 Native Code spent same time to finish the iteration, while VBNet is 2 times faster (spent mush less time) than C# & VB6 both.
Is any one there would like to tell me why? It will be highly appreciated.CG