在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
先定义两个函数 function sumX(x, y: Integer): Integer; function sumY(x, y: Integer): Integer; inline; 计算函数执行时间 procedure TForm5.Button5Click(Sender: TObject); var sw: TStopwatch; i, j: Integer; begin j := 0; sw := TStopwatch.StartNew; for i := 0 to 100000000 do begin j := sumX(i, j); //普通函数 end; sw.Stop; ShowMessage('first do expand time =' + IntToStr(sw.ElapsedMilliseconds) + ' '); //602 j := 0; sw := TStopwatch.StartNew; for i := 0 to 100000000 do begin j := sumY(i, j); //inline函数 end; sw.Stop; ShowMessage('second do expand time =' + IntToStr(sw.ElapsedMilliseconds) + ' '); //595 end;
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论