Delphi与C#的一点对比

Neo2D 2001-05-20 10:28:00
初步学习了一下C#,以前是用的Delphi,所以忍不住拿来对比了一下。
全面的评比是不可能的,只是写了个小程序分别比较了几个编译器产生
的执行文件的速度,很简单,一个for循环,循环体里做一次加法,一次
乘法,一次API调用。优化选项全开。
结果如下:
Delphi: 2.1s
C#: 38s
参考:
BCB: 2.1s
VC: 1.7s
...全文
396 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
lichp 2001-05-20
  • 打赏
  • 举报
回复
呵呵,也好,了解一下
Neo2D 2001-05-20
  • 打赏
  • 举报
回复
BCB的就不用贴了吧。
to jokerman(): 我并不是想说明谁好谁不好,只是学习之前希望尽量多的了解。
没有想掀起编译器论战的意思。刚好机器上装全了几个编译器,比一比,当是
星期天的消遣而已。不管怎么讲,知道比不知道好,你说是不是。
看看for循环是因为有一个高人说VC的for循环优化得没Delphi好,我想自己试试。
结果是:如果循环体内东西很简单则Delphi快点,但一般还是VC快点。都是小小
的差别。
Neo2D 2001-05-20
  • 打赏
  • 举报
回复
VC的:
..........
case IDYES:
t=0;
m=7;
n=3;
j=3000;
t=timeGetTime();
for (i=0;i<=j;i++)
{
for (k=0;k<=j;k++)
{
m-=timeGetTime();
n+=m;
m+=n;
n*=m;
m*=n;
}
}
t=timeGetTime()-t;
ltoa(t,temp,10);
SetWindowText(hWnd,LPCTSTR(temp));
break;
........
jokerman 2001-05-20
  • 打赏
  • 举报
回复
这种比较没多大意思,开发软件的目的是什么,是为了满足用户特定的需要,检验一个软件好坏的标准不再于你选择哪一种开发语言或开发工具,无论怎样,你只要能实现用户的需求,你就是成功的,当然前提是在规定的范围、时间和预算内。
heifei 2001-05-20
  • 打赏
  • 举报
回复
别的呢
heifei 2001-05-20
  • 打赏
  • 举报
回复
别的呢
Neo2D 2001-05-20
  • 打赏
  • 举报
回复
C#的:
namespace WindowsApplication1
{
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.WinForms;
using System.Data;

/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.WinForms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components;
private System.WinForms.Button button1;

public uint m, n, t;
[sysimport(dll="winmm.dll")]
public static extern uint timeGetTime();
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
public override void Dispose()
{
base.Dispose();
components.Dispose();
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container ();
this.button1 = new System.WinForms.Button ();
//@this.TrayHeight = 0;
//@this.TrayLargeIcon = false;
//@this.TrayAutoArrange = true;
button1.Location = new System.Drawing.Point (184, 152);
button1.Size = new System.Drawing.Size (75, 23);
button1.TabIndex = 0;
button1.Text = "button1";
button1.Click += new System.EventHandler (this.button1_Click);
this.Text = "Form1";
this.AutoScaleBaseSize = new System.Drawing.Size (6, 14);
this.Controls.Add (this.button1);
}

protected void button1_Click (object sender, System.EventArgs e)
{
uint i,j,k;
t=0;
m=7;
n=3;
j=3000;
t=timeGetTime();

for (i=0;i<=j;i++)
{
for (k=0;k<=j;k++)
{
m-=timeGetTime();
n+=m;
m+=n;
n*=m;
m*=n;
}
}
t=timeGetTime()-t;
this.Text=t.ToString();
}

/// <summary>
/// The main entry point for the application.
/// </summary>
public static void Main(string[] args)
{
Application.Run(new Form1());
}
}
}
Neo2D 2001-05-20
  • 打赏
  • 举报
回复
Delphi的:
var
Form1: TForm1;
m,n,t: Dword;
implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
i,j,k: Dword;
begin
n:=7;
m:=3;
j:=3000;
t:=timegettime;
for i:=0 to j do
for k:=0 to j do
begin
m:=m-timeGetTime();
n:=n+m;
m:=m+n;
n:=n*m;
m:=m*n;
end;
Caption:=IntToStr(timegettime-t);
end;
comsun 2001-05-20
  • 打赏
  • 举报
回复
公开你的程序,让多个人也测试一下,证明一下 Delphi的强大。
hxshanji 2001-05-20
  • 打赏
  • 举报
回复
18倍??~!!!

830

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧