bryan7
asked on
AnsiString manipulation extremelly slow (D2009)
Is this normal???
// ansistring test
Var a: ansistring;
b: integer;
PerfTimerInit;
for b:= 0 to 50000 do
a:= a+chr(random(256));
caption:= inttostr(PerfTimerStop);
// 3977 ms
// string test
Var a: string;
b: integer;
PerfTimerInit;
for b:= 0 to 50000 do
a:= a+chr(random(256));
caption:= inttostr(PerfTimerStop);
// 2ms
Uses Windows;
procedure PerfTimerInit;
function PerfTimerStop: Integer;
Var PF, PC0, PC1: Int64;
implementation
procedure PerfTimerInit;
begin
QueryPerformanceFrequency(PF);
QueryPerformanceCounter(PC0);
end;
function PerfTimerStop: Integer;
begin
QueryPerformanceCounter(PC1);
Result:= ((PC1-PC0)*1000) div PF
end;
in delphi 2009 all string is widestring ...
ASKER
that doesn't explain what's wrong with the 1st test
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.