Home > Back-end >  Read speed of files
Read speed of files

Time:10-04

I have a hex file, according to the fixed length intercept record (100000) are possible, and keep the records according to its location intercept corresponding values, don't know how to deal with the speed will be hurry up,

I now is through the FileStream read file, and then according to the fixed-length interception, feeling speed is slow!
Don't know you have what good method,

 
Var
ValueBytes: an Array of byte;
Fs: TFileStream;
The begin
.
Fs:=TFileStream. Create (' \ jywj \ '+ jyfilename, fmOpenRead);
SetLength (ValueBytes, fs. Size);
Fs. Read (ValueBytes [0], fs, Size);
For k=0 to ((length (ValueBytes) - 28) div 374-1) do//(length (ValueBytes) - 28) 374
divThe begin
Form_rzcl. ADOQuery. Close;
Form_rzcl. ADOQuery. SQL. The Clear;
Form_rzcl. ADOQuery. SQL. The Add (' insert into log_zw (cx, have, CZRQ WJJMC, RZWJ, jywj, Type, CarNo, CodeID, Count, DateTimeOccUTC, DateTimeGoneUTC, EventCount, EventStatus) ');
Form_rzcl. ADOQuery. SQL. The Add (' values (cx, : have, : CZRQ, : WJJMC, : RZWJ, : jywj, : Type, :, CarNo: CodeID, : Count, : DateTimeOccUTC, : DateTimeGoneUTC, : EventCount, : EventStatus) ');
Form_rzcl. ADOQuery. The Parameters. ParamByName (' cx). Value:=cx.
Form_rzcl. ADOQuery. The Parameters. ParamByName (' have '). The Value:=k + 1;
Form_rzcl. ADOQuery. The Parameters. ParamByName (' CZRQ). Value:=FormatDateTime (' MM - DD YYYY - HH: MM: ss ', Now ());
Form_rzcl. ADOQuery. The Parameters. ParamByName (' WJJMC). Value:=WJJMC;
Form_rzcl. ADOQuery. The Parameters. ParamByName (' RZWJ). Value:=filename;
Form_rzcl. ADOQuery. The Parameters. ParamByName (' jywj). Value:=jyfilename;
Form_rzcl. ADOQuery. The Parameters. ParamByName (' type '). The Value:=PSmallInt (@ ValueBytes 28 + k * [374]) ^;
Form_rzcl. ADOQuery. The Parameters. ParamByName (" CarNo "). The Value:=PInteger (@ ValueBytes [34 + k * 374]) ^;
Form_rzcl. ADOQuery. The Parameters. ParamByName (' CodeID). Value:=PInteger (@ ValueBytes [50 * 374 + k]) ^;
Form_rzcl. ADOQuery. The Parameters. ParamByName (" Count "). The Value:=PSmallInt (@ ValueBytes [56 + k * 374]) ^;
Form_rzcl. ADOQuery. The Parameters. ParamByName (' DateTimeOccUTC). Value:=UTimeToDateTime (PInteger (@ ValueBytes 60 + k * [374]) ^);
Form_rzcl. ADOQuery. The Parameters. ParamByName (' DateTimeGoneUTC). Value:=UTimeToDateTime (PInteger (@ ValueBytes [68 * 374 + k]) ^);
Form_rzcl. ADOQuery. The Parameters. ParamByName (' EventCount). Value:=PInteger (@ ValueBytes [76 * 374 + k]) ^;
Form_rzcl. ADOQuery. The Parameters. ParamByName (' EventStatus). Value:=PSmallInt (@ ValueBytes [80 * 374 + k]) ^;
Form_rzcl. ADOQuery. Prepared;
Form_rzcl. ADOQuery. ExecSQL;
end;

.


CodePudding user response:

According to the terms of the structure of your data,
The file into a a SQL insert statement, with a semicolon (;) Separated,
Then use AdoQuery join multiple lines, 1000 lines, for example, faster to implement, a lot of

CodePudding user response:

Article 100000 data, one-time read memory of a little big, can be directly offset + fixed-length read a single data, using the fs, siza div fixed-length determine cycles, use append submit post model, I think will be faster than SQL insert mode,
  • Related