Registriert seit: 20. Jan 2006
Ort: Lübbecke
11.453 Beiträge
Delphi 12 Athens
|
AW: KodeZwergs TIniHelper Klasse
17. Nov 2018, 17:12
Delphi-Quellcode:
program Project445;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
System.NetEncoding,
System.Diagnostics,
IdCoderMIME,
IdGlobal;
var
Value: TBytes = nil;
Indies: TIdBytes = nil;
function Net: string;
begin
Result := TNetEncoding.Base64.EncodeBytesToString(Value);
end;
function Indy: string;
var
Encoder: TIdEncoderMIME;
begin
Encoder := TIdEncoderMIME.Create( nil);
try
Result := Encoder.EncodeBytes(Indies);
finally
Encoder.Free;
end;
end;
procedure InitValue;
var
I: Integer;
begin
SetLength(Value, 10*1024);
SetLength(Indies, 10*1024);
for I := 0 to Length(Value) - 1 do begin
Value[I] := Random(256);
Indies[I] := Value[I];
end;
end;
var
sw: TStopWatch;
I: Integer;
begin
try
InitValue;
sw := TStopWatch.StartNew;
for I := 1 to 100000 do
Net;
Writeln(sw.ElapsedMilliseconds);
sw := TStopWatch.StartNew;
for I := 1 to 100000 do
Indy;
Writeln(sw.ElapsedMilliseconds);
except
on E: Exception do
Writeln(E.ClassName, ' : ', E. Message);
end;
Readln;
end.
|
|
Zitat
|