Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program stings;
- {$APPTYPE CONSOLE}
- {$R *.res}
- uses
- Windows,
- System.SysUtils;
- const
- Buffer: string = 'halalconta';
- var
- Test: string;
- begin
- try
- var Start := GetTickCount;
- for var Round := 1 to 100000 do
- begin
- Test := '';
- for var Index := 1 to 1000 do
- Test := Test + Buffer;
- end;
- var TimeSpanS := GetTickCount - Start;
- WriteLn(Test.Substring(0, 32));
- var Builder := TStringBuilder.Create;
- Start := GetTickCount;
- for var Round := 1 to 100000 do
- begin
- Builder.Length := 0;
- for var Index := 1 to 1000 do
- Builder.Append(Buffer);
- end;
- var TimeSpanB := GetTickCount - Start;
- WriteLn(Builder.ToString(0, 32));
- SetLength(Test, 10000);
- Start := GetTickCount;
- for var Round := 1 to 100000 do
- for var Index := 0 to 999 do
- Move(PByte(Buffer)^, Test[Index * 10 + 1], 20);
- var TimeSpanM := GetTickCount - Start;
- WriteLn(Test.Substring(0, 32));
- WriteLn(Format('Concat: %d ms, Builder: %d ms, Move: %d ms', [TimeSpanS, TimeSpanB, TimeSpanM]));
- except
- on E: Exception do
- Writeln(E.ClassName, ': ', E.Message);
- end;
- ReadLn;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement