呵呵,我自己测试了一下,测试结果如下:
const: 0.307360s
none: 18.169158s
var: 3.326552s
测试代码如下,由于为了减小多任务的影响,程序的运行优先级设为最高,
所以运行时就像死机一样,耐心等待就可以了
procedure TForm1.Button1Click(Sender: TObject);
var
t1, t2, tc: Int64;
s1, s2, s3, s: String;
i: Integer;
begin
SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS);
SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL);
QueryPerformanceFrequency(tc);
s := 'this a test string, hello';
QueryPerformanceCounter(t1);
for i := 1 to 10000000do
begin
a(s);
end;
QueryPerformanceCounter(t2);
s1 := Format('%.6f', [(t2 - t1)/tc]);
QueryPerformanceCounter(t1);
for i := 1 to 100000000do
begin
b(s);
end;
QueryPerformanceCounter(t2);
s2 := Format('%.6f', [(t2 - t1)/tc]);
QueryPerformanceCounter(t1);
for i := 1 to 100000000do
begin
c(s);
end;
QueryPerformanceCounter(t2);
s3 := Format('%.6f', [(t2 - t1)/tc]);
SetPriorityClass(GetCurrentProcess, NORMAL_PRIORITY_CLASS);
SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_NORMAL);
ShowMessage(s1 + ',' + s2 + ',' + s3);
end;
: