Link to home
Start Free TrialLog in
Avatar of bryan7
bryan7Flag for Japan

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;

Open in new window

Avatar of wd123
wd123
Flag of Belarus image

in delphi 2009 all string is widestring ...
Avatar of bryan7

ASKER

that doesn't explain what's wrong with the 1st test
ASKER CERTIFIED SOLUTION
Avatar of ChristianWimmer
ChristianWimmer
Flag of Albania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial