Zw.delphi different versions of program run Speed test

Source: Internet
Author: User

{Zw.delphi Different versions of the program run Speed Test Delphi Whether it is development, compile, or run, the speed has always been not bad, I seldom do this particle size optimization, debugging, recently, because the project needs, found: The same function module, almost the same code, after the upgrade,   2-3 times slower than 2007 involves strings, Thashedlist, at first, the feeling is Uncode string function, replacing the qstring function of the problem. After testing, found that: in the short string aspect, Thashedstringlist, even the string returns aspect, the Xe10 optimizes better, is faster than the d2007 speed 20-50%, the real bottleneck, appears in Xe10 for the long string (>500k) processing,   Especially lowercase functions, xe10 version is 3 times times slower than d2007.   ----------------------------------------------for the sake of fairness, the relevant test functions are written in pure Pascal. Theoretically, applicable to D7 and other versions of Delphi, has been tested in D2007,XE10 test environment: win7+64 bit, notebook: i7-3720qm,8g memory test results are as follows: tst001, @d2007, tn,6708 MS, @xe. 10,tn , 3962 MS, focused test thashedstringlist,xe10 faster than d2007 tst002, @d2007, tn,4227 MS, @xe. 10,tn,2231 MS, Test short string substitution (<500) tst003,@ D2007,tn,6100 MS, @xe. 10,tn,4290 ms, Test long string substitution (>500k) tst004, test other string functions, long string (>500k) lowercase, @d2007, tn,296 ms,@ xe.10,tn,1092 Ms,!!! Bottleneck Leftstr, @d2007, tn,281 MS, @xe. 10,tn,390 msrightstr, @d2007, tn,281 MS, @xe. 10,tn,390 mspos, @d2007, tn,156 MS, @xe. 10,tn  , 203 ms}//---------test code function TST_STR1 (): String;var I,j,k1,t0,t2,tn:integer;  s2,kss,dss,ess,vss:string; Xlib:thashedstRinglist;begin//Key test thashedstringlist xlib:=thashedstringlist.create;    With Mwin do begin Msg.lines.add ("); t0:=gettickcount;      For i:=0-to-do begin kss:= ' XK ' +inttostr (i+10000);      dss:= ' DX ' +inttostr (i+10000); Xlib.    VALUES[KSS]:=DSS;    End    T2:=gettickcount;        ---TST for i:=1 to ten do for j:=1 to + do begin kss:= ' XK ' +inttostr (j+10000); S2:=xlib.   VALUES[KSS];S2:=DSS+S2;   End   T2:=gettickcount;tn:=t2-t0;  S2:= ' Tst001,tn, ' +inttostr (TN) + ' MS '; Msg.lines.add (S2);  End  Xlib.free;end;function tst_str2 (): String;var I,j,k1,t0,t2,tn:integer;    S2,dss,ess,vss:string;begin//test short string substitution (<500) with Mwin do begin Msg.lines.add ("); t0:=gettickcount;    vss:= ' abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz ';    For I:=1-to-j:=1-to-do begin Dss:=stringreplace (VSS, ' EFG ', ' 123 ', [rfreplaceall,rfignorecase]);    End  T2:=gettickcount;tn:=t2-t0;s2:= ' Tst002,tn, ' +inttostr (TN) + ' MS '; Msg.lines.add (S2); End;end;function TST_STR3 (): String;var I,j,k1,t0,t2,tn:integer;    S2,dss,ess,vss:string;begin//test long string substitution (>500k) with Mwin do begin Msg.lines.add (");    s2:= ' abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz ';    For i:=1 to vss:=vss+ ', ' +s2;    T0:=gettickcount;    For I:=1 to 2 does for j:=1 to 5 does begin dss:=stringreplace (VSS, ' EFG ', ' 123 ', [rfreplaceall,rfignorecase]);    End  T2:=gettickcount;tn:=t2-t0;s2:= ' Tst003,tn, ' +inttostr (TN) + ' MS '; Msg.lines.add (S2);  End;end;function TST_STR4 (): String;var I,j,k1,t0,t2,tn:integer;    S2,dss,ess,vss:string;begin//Test long string function (>500k) with Mwin do begin Msg.lines.add (");    s2:= ' abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz ';    For i:=1 to vss:=vss+ ', ' +s2;    vss:= ' +vss+ ';    --T0:=gettickcount;for I:=1 to ten do for j:=1 to + do Dss:=lowercase (VSS);    T2:=gettickcount;tn:=t2-t0;s2:= ' Tst004,lowercase,tn, ' +inttostr (TN) + ' MS '; Msg.lines.add (S2); ---t0:=gettickcount;for i:=1 toFor J:=1 to S2:=leftstr (vss,100);    T2:=gettickcount;tn:=t2-t0;s2:= ' Tst004,leftstr,tn, ' +inttostr (TN) + ' MS '; Msg.lines.add (S2);    --T0:=gettickcount;for I:=1 to + do-j:=1 to-do s2:=rightstr (vss,100);    T2:=gettickcount;tn:=t2-t0;s2:= ' Tst004,rightstr,tn, ' +inttostr (TN) + ' MS '; Msg.lines.add (S2);    --T0:=gettickcount;for i:=1 to the j:=1 do K1:=pos (' EFG ', VSS);  T2:=gettickcount;tn:=t2-t0;s2:= ' Tst004,pos,tn, ' +inttostr (TN) + ' MS '; Msg.lines.add (S2); End;end;

  

Zw.delphi different versions of program run Speed test

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.