Reading files is an important part of my project.
I didn't share the complete code, but I'm using GetTickCount64 () to calculate the time.
The code has WriteLn(), but they are never called. Just to display the benchmark.
I updated the code to work with JSONTools.
With JSONTools the code is 20 seconds faster. However, 120 seconds is still slow.
procedure TMyApplication.DoRun;
var
ACmd : String;
ATime : QWord;
AItens : TJsonNode;
N : TJsonNode;
i, j, k : Integer;
a : String;
b, c, d, e : Double;
f : Integer;
begin
ATime := GetTickCount64();
for i := 0 to 999 do
begin
for j := 1 to 15 do
begin
N := TJsonNode.Create;
try
N.LoadFromFile( 'C:\xampp\htdocs\teste_json\' + IntToStr( j ) + '.txt' );
AItens := N.Child('Data').AsArray;
for k := 0 to ( AItens.Count - 1 ) do
begin
with AItens.Child( k ) do
begin
a := Find('Data').AsString;
b := Find('Open').AsNumber;
c := Find('Close').AsNumber;
d := Find('High').AsNumber;
e := Find('Low').AsNumber;
f := Trunc( Find('Volume').AsNumber );
end;
if ( Length(a) > 50 ) then
begin
a := 'sdsdsd';
//WriteLn( a );
end;
if ( b > 10000000 ) then
begin
b := 100;
//WriteLn( FloatToStr( b ) );
end;
if ( c > 10000000 ) then
begin
c := 100;
//WriteLn( FloatToStr( c ) );
end;
if ( d > 10000000 ) then
begin
d := 100;
//WriteLn( FloatToStr( d ) );
end;
if ( e > 10000000 ) then
begin
e := 100;
//WriteLn( FloatToStr( e ) );
end;
if ( f > 10000000 ) then
begin
f := 100;
//WriteLn( FloatToStr( f ) );
end;
end;
finally
N.Free;
end;
end;
end;
WriteLn( IntToStr( GetTickCount64() - ATime ) );
ReadLn( ACmd );
// stop program loop
Terminate;
end;