Virtual ListView效率对比
第一次注釋掉Lv1的循環、運行Lv2的代碼、
第二次注釋掉Lv2的循環、運行Lv1的代碼、
具體運行速度、完全不用計時、顯而易見、在我的電腦上、Virtual ListView的速度幾乎是一瞬間就好了
不過蠻奇怪的、我又用VB做了下實驗、VB的ListView是ActiveX的、在IDE下添加100000條記錄、速度也蠻快的、大概在我的電腦上是2.5s左右、這是IDE下的速度、如果是生成EXE再運行應該是可以在1s以內的、這個速度遠遠大于Delphi中的Vcl ListView....看來這個效率損耗在VCL里挺大的、、
僅以此做記錄、以后不要忘記了ListView的這種用法、、
?unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls; type TForm1 = class(TForm) lv1: TListView; lv2: TListView; procedure FormCreate(Sender: TObject); procedure lv2Data(Sender: TObject; Item: TListItem); private { Private declarations } public { Public declarations } end; var Form1: TForm1; s:TStringList; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); var Lv1Timer,Lv2Timer:Cardinal; nLoop:Cardinal; const AddStr='Test'; LoopTimes=100000; begin s:=TStringList.Create; lv1.ViewStyle:=vsList; lv2.ViewStyle:=vsList; Lv1Timer:=GetTickCount; //for nLoop := 1 to LoopTimes do //第一次運行、注釋掉這兩行、體驗下速度 // lv1.Items.Add.Caption:=AddStr + IntToStr(nLoop); Lv1Timer:=GetTickCount - Lv1Timer; Lv2Timer:=GetTickCount; lv2.OwnerData:=True; //for nLoop := 1 to LoopTimes do //第二次運行、注釋掉這兩行、看看Lv1是什么速度 // s.Add(AddStr + IntToStr(nLoop)); lv2.Items.Count:=LoopTimes; Lv2Timer:=GetTickCount - Lv2Timer; //s.Free; ShowMessage('Time Out:' + #13#10 + //這個計時對于Lv2來說是不準確的、 'Lv1:' + IntToStr(Lv1Timer) + ' ms' + #13#10 + //不過這個明顯的速度差異、 'Lv2:' + IntToStr(Lv2Timer) + ' ms');//人也可以感覺出來了 end; procedure TForm1.lv2Data(Sender: TObject; Item: TListItem); begin Item.Caption:=s[Item.Index]; end; end.
轉載于:https://www.cnblogs.com/ForDream/archive/2010/08/17/1924465.html
總結
以上是生活随笔為你收集整理的Virtual ListView效率对比的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: FreeBSD 6.0架设管理与应用-附
- 下一篇: 递归上传文件和文件夹至SharePoin