Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

AnsiString manipulation extremelly slow (D2009)

Posted on 2008-10-18
3
Medium Priority
?
263 Views
Last Modified: 2010-04-05
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

0
Comment
Question by:bryan7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Expert Comment

by:wd123
ID: 22747642
in delphi 2009 all string is widestring ...
0
 
LVL 3

Author Comment

by:bryan7
ID: 22747649
that doesn't explain what's wrong with the 1st test
0
 
LVL 6

Accepted Solution

by:
ChristianWimmer earned 100 total points
ID: 22763054
Chr returns a widechar which is converted to ansichar with a call to WideCharToMultiByte. At least I would believe this. The CPU window should confirm or deny it.
btw: String is a UnicodeString, not a WideString. US is unlike to WS reference counted as old String. WS is for COM support which uses BSTR.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question