Redian新闻
>
why vb code faster than csharp???
avatar
why vb code faster than csharp???# Programming - 葵花宝典
s*1
1
芝加哥北郊Glenview 诚请保姆, 照顾一个刚2岁的女孩. 住家或往返都考虑. 每周5-6
天. 工作量轻, 待遇优, 住宿环境好. 请电8477304009.
avatar
e*r
2
Anybody can tell why vb.net codes for looping is faster than Csharp?
avatar
s*o
3
How do you know that vb.net is faster than C# for looping?
avatar
v*n
4
it's possible that VB compiler does more optimization than C# compiler

【在 e*****r 的大作中提到】
: Anybody can tell why vb.net codes for looping is faster than Csharp?
avatar
a*l
5
it's much more possible that LZ just mistakenly thought vb is faster. VB,
especially after VB6, is based on .net framework, so its code is not much
different from C# code.

【在 v******n 的大作中提到】
: it's possible that VB compiler does more optimization than C# compiler
avatar
e*r
6
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using System.IO;
namespace My_Speed_Test
{
class Program
{
static void Main(string[] args)
{
DateTime tic = DateTime.Now;
UInt32 d=200;
double dd = 200;
int s = 0;
for (int a=1;a<=10000;a++)
{
for (int b=1;b<=10000;b++)
{
for (int c=1;c<=10;c++)
avatar
e*r
7
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim a, b, c, s As Integer
s = 0
Dim d As Integer
d = 250
Dim dd As Double
dd = 250
Dim tic, toc As String
tic = (Now().Millisecond) / 1000 + Now().Second + (Now().Minute) *
60
For a = 1 To 10000
For b = 1 To 10000
For c = 1 To 10
dd = dd * 5.1234567
avatar
e*r
8
above are C# codes and vb.net codes respectively(both compiled by vs.net 2008 Express):
In my laptop, results for speed testing:
Matlab:
ver 7.1: limit of array size overlimit for 1E4*1e4*1e1 size, has to
change to loop format 20x for loop
Total time: 38.01second
VB.net: total loop 1e9 (1 billion)
total time: 18.64 second
VSharp.net:
total time:21.5 second!!!
netSDK_CSC:
total time: 21.625 second!!!
Python 2.5:
10000x1000x10 loops with For-Loop (it's a very special one!)
avatar
e*r
9
It can't be interpreted simply by "overhead" costs (>3 second difference
between vb.net and C# codes), since there is no overhead (to my
understanding) between the two. CIL codes for both C# and VB.net should be
the same for both, aren't they?
I have been expecting vb.net "FOR loop" will be slower than that of C# due to
some overhead costs, but instead! no!
avatar
c*t
10
why not use exactly same init and format for both VB.NET and C#?

to

【在 e*****r 的大作中提到】
: It can't be interpreted simply by "overhead" costs (>3 second difference
: between vb.net and C# codes), since there is no overhead (to my
: understanding) between the two. CIL codes for both C# and VB.net should be
: the same for both, aren't they?
: I have been expecting vb.net "FOR loop" will be slower than that of C# due to
: some overhead costs, but instead! no!

avatar
g*n
11
你反编译一下Assembly,看一下生成的IL指令不就知道原因了?
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。