51

Re: Optimization of byte reading and comparing of two binary files

YuRock wrote:

If you still would find and compared not , and there, on 16, I am afraid to present even, as though you for such speed reacted. And without .
But, can, so it is necessary, I did not press.

It and truth there it is necessary to analyze each byte, therefore on 16 it does not turn out in any way!. (
In the very first post of the given topic I tried to paint an essence of the present procedure, instead of test, and the code in the same place is available!
Truth in it like is one algorithmic error (as I already corrected it for today) and is possible - inaccuracies with the output analysis for limits of files.

52

Re: Optimization of byte reading and comparing of two binary files

Bellic;
The coolest that 2,5 seconds - not a limit
ReadData is a high-level function. If to learn to work on a low level - it is possible to read the data directly, now  64. But it is difficult, at least for your level, therefore I recommend not  smile

53

Re: Optimization of byte reading and comparing of two binary files

SOFT FOR YOU wrote:

Bellic;
Dock initially was in Russian, and it was then translated to an English. A source code not to find any more. It is possible to translate docks in Google, it is possible to look demos, it is possible to write on a forum: http://www.sql.ru/forum/1178076-a/ofici … hedbuffers

SOFT FOR YOU , well and here it is possible to ask still?
Easier completely to forward Real my procedure - it is necessary to replace with your analogs here it:

FilesPos: = FOriginal. Position;//FOriginal: TFileStream;

and in :

FOriginal. Position: = FilesPos;

Well I will once again be specified:

FROriginal. ReadData (ISimvol);

Automatically moves a position on the following byte, how ReadBuffer in TFileStream ?

54

Re: Optimization of byte reading and comparing of two binary files

Bellic;
ReadData shifts a position, yes
In the reader you as can learn a position through property Position
But here customary Seek and SetPosition it is not provided. If you read the data - return back you cannot. You can pass some byte in front through function Skip. You can read the arbitrary piece by means of function DirectRead. For example, you know that on such offset there is a line so much that byte. Then you can cause DirectRead. But generally it not faster normal reading from a file, unless if this piece already  in the buffer. And DirectRead does not change current position of the reader.

55

Re: Optimization of byte reading and comparing of two binary files

SOFT FOR YOU wrote:

Bellic;
ReadData shifts a position, yes
In the reader you as can learn a position through property Position
But here customary Seek and SetPosition it is not provided. If you read the data - return back you cannot. You can pass some byte in front through function Skip. You can read the arbitrary piece by means of function DirectRead. For example, you know that on such offset there is a line so much that byte. Then you can cause DirectRead. But generally it not faster normal reading from a file, unless if this piece already  in the buffer. And DirectRead does not change current position of the reader.

In general that at me in Real procedure goes byte-serial serial reading and comparing, but only till the certain moment when one of checks works.
In this place the Main position is remembered and reading and the analysis to other address begins.
Then there can be a further reading to remembered Osn.pozitsii, or it moves ahead on certain number byte.
Here such description I hope clearly?
Not absolutely understood - I can install the Position through "property Position";
And to rise on remembered earlier - in any way???

56

Re: Optimization of byte reading and comparing of two binary files

Bellic;

wrote:

English language sometimes happens is a little dryish and does not transfer some nuances of a Russian-speaking variant! Isn't that so?.)))

If the text wrote with good knowledge of language all there will be excellent. Well and at level of guglo-transfer of the documentation, of course, will be dry smile

wrote:

It and truth there it is necessary to analyze each byte, therefore on 16 it does not turn out in any way.

That hinders to make the elementary buffer in storage on 8-16 , probably, and remains for us a riddle smile

57

Re: Optimization of byte reading and comparing of two binary files

10 Mb can be subtracted easily entirely in storage and there to understand. What for all these complexities? All right was would like . And that.

58

Re: Optimization of byte reading and comparing of two binary files

Misters, well it is real - 5 code lines smile well  it is all? The second week of development! Same a hell any smile

59

Re: Optimization of byte reading and comparing of two binary files

makhaon wrote:

10 Mb can be subtracted easily entirely in storage and there to understand. What for all these complexities? All right was would like . And that.

Yes here - wanted with Memory to be puzzled, yes SOFT FOR YOU started to take offense on ostensibly  its libraries.)))
Felt, it was pleasant! - here I wait for specification on the questions!
The following variant it will be mandatory with Memory !.)))

60

Re: Optimization of byte reading and comparing of two binary files

makhaon wrote:

misters, well it is real - 5 code lines smile well  it is all? The second week of development! Same a hell any smile

makhaon , sorry certainly...
1 . 5 code lines are in the Test unique cycle - for the sake of comparing!!!
2 . And anybody here by force holds nobody in this topic!.)))

61

Re: Optimization of byte reading and comparing of two binary files

Well not the developer I!!!.)))
is my assistant in my hobby - localizations Japanese ( JDM ) radio tape recorders!
The main time in the afternoon - I carry another's children in school, a garden, on sport complexes and it is reverse...
Into Delfi and JDM I run by fits, therefore occasionally and some my "thoughtfulness" in answers and decisions!,))

62

Re: Optimization of byte reading and comparing of two binary files

Bellic;
To read Position it is possible, to install Position - it is impossible
This  intends for operation with gigabytes of the data. Well or at least in hundreds megabytes. And if files on 10 meters - it is finite, read them in the buffer and process entirely

63

Re: Optimization of byte reading and comparing of two binary files

Bellic wrote:

the Following variant it will be mandatory with Memory !.)))

In the first variant replace file  on TMemoryStream; For example, so:

var FOriginal: TMemoryStream;
//
//FOriginal: = TFileStream. Create (FullOriginalFileName, fmOpenRead, fmshareCompat);
//
FOriginal: = TMemoryStream. Create;
FOriginal. LoadFromFile (FullOriginalFileName);

...And all remaining leave without changes (will work both Seek and Position).

64

Re: Optimization of byte reading and comparing of two binary files

SOFT FOR YOU wrote:

Bellic;
To read Position it is possible, to install Position - it is impossible
This  intends for operation with gigabytes of the data. Well or at least in hundreds megabytes. And if files on 10 meters - it is finite, read them in the buffer and process entirely

it is not foreseen yet...))
Today 10 Meters, and can be tomorrow already and more! - Always it is convenient to have near at hand suitable and checked tools!))

65

Re: Optimization of byte reading and comparing of two binary files

Kazantsev Alexey, thanks!
I already on "wheels"...)))
already concerned it is sensitive here:
http://www.sql.ru/forum/1276254/poisk-i … rnom-fayle

66

Re: Optimization of byte reading and comparing of two binary files

Kazantsev Alexey;
Yes let works with TBytes

67

Re: Optimization of byte reading and comparing of two binary files

SOFT FOR YOU wrote:

Yes let works with TBytes

I too would like with it , but I still never with it worked!
It is type files in a byte-file?
While by the night a computer I will reach - it is possible it is sensitive the code, for a seed?.)))

68

Re: Optimization of byte reading and comparing of two binary files

Bellic wrote:

Memori already concerned is sensitive here

I see, you do not search for easy ways smile

69

Re: Optimization of byte reading and comparing of two binary files

Kazantsev Alexey wrote:

it is passed...
So the easy way () in that procedure generally worked 24 hours!.)))))
- solved a problem!

70

Re: Optimization of byte reading and comparing of two binary files

SOFT FOR YOU wrote:

And there is a claim to me personally or to my code?

Pardon, what claims? 8-o
We with you in different fields are grazed smile

71

Re: Optimization of byte reading and comparing of two binary files

Bellic;

function LoadFileData (const FileName: string): TBytes;
var
F: TFileStream;
Len: Integer;
begin
F: = TFileStream. Create (FileName, fmRead);
try
Len: = F.Size;
SetLength (Result, Len);
F.ReadBuffer (Pointer (Result) ^, Len);
finally
F.Free;
end;
end;

72

Re: Optimization of byte reading and comparing of two binary files

Read all in storage!!! Well truth, so fastest.
One decision already threw.
Still:

Bytes: = TFile. ReadAllBytes (' 1.bin ');

You will have an array byte with which can make everything and somehow smile

73

Re: Optimization of byte reading and comparing of two binary files

wrote:

It is type files in a byte-file?

It is an array byte. A piece of storage which is displayed as n successively going byte. Access - as to any normal array on an index: arr [i]. Both on record and on reading. Easier, in general, there is no place smile

74

Re: Optimization of byte reading and comparing of two binary files

Bellic wrote:

the Following variant it will be mandatory with Memory !.)))

The variant on TMemoryStream is ready...
Here its code (all the same procedure with one cycle, reading and comparing from two files):
[spoiler]

procedure TMainForm. TestButtonClick (Sender: TObject);
var
SizeOriginal: Integer;
SizePereveden: Integer;
FMOriginal: TMemoryStream;
FMPereveden: TMemoryStream;
begin
try
//we Read out names of files from editing Fields (were probably edited!)
FullOriginalFileName: = FileBinOriginalEdit. Text;//these files -
FullPerevedenFileName: = FileBinPerevedenEdit. Text;//were already checked
FullPerevodFileName: = DirPerevodEdit. Text + PerevodFileNameEdit. Text;
FMOriginal: = TMemoryStream. Create;
FMPereveden: = TMemoryStream. Create;
FMOriginal. LoadFromFile (FullOriginalFileName);
FMPereveden. LoadFromFile (FullPerevedenFileName);
SizeOriginal: = FMOriginal. Size;
SizePereveden: = FMPereveden. Size;
if SizeOriginal <> SizePereveden then
begin
ShowMessage (' Lengths of BIN-files are not equal! ' + #10#13 +
' Continuation of process of handling - Is impossible! ');
Exit;
end;
AddressFiles: = 0;
StartTime: = Now;//we Fix Start time
//===== Rose on the Beginning in Both files =====
//FMOriginal. Seek (AddressFiles, soFromBeginning);
//FMPereveden. Seek (AddressFiles, soFromBeginning);
while AddressFiles <= SizeOriginal-1 do
begin
FMOriginal. ReadBuffer (ISimvol, 1);
FMPereveden. ReadBuffer (PSimvol, 1);
Inc (AddressFiles);
//we Search for coincidence Zero byte
if (ISimvol=0) and (PSimvol=0) then
begin
//
end;
end;
finally
FMOriginal. Free;
FMPereveden. Free;
EndTime: = Now;//we Fix STOP time
DelayTime: = SecondSpan (EndTime, StartTime);//we Calculate PROCEDURE runtime
MainMemo. Lines. Add (' Test run of files in a mode "MemoryStream" is completed! ' + #13#10 +
' test Time = ' + FloatToStr (DelayTime) + ' sec ');
end;
end;

[/spoiler] Received time of a cycle - 2,15 seconds!.)))
Excellent result, and without .!

75

Re: Optimization of byte reading and comparing of two binary files

The next variant on a basis TBytes ...
[spoiler]

procedure TMainForm. TestButtonClick (Sender: TObject);
var
SizeOriginal: Integer;
SizePereveden: Integer;
i: integer;
BOriginal: TBytes;
BPereveden: TBytes;
begin
try
//we Read out names of files from editing Fields (were probably edited!)
FullOriginalFileName: = FileBinOriginalEdit. Text;//these files -
FullPerevedenFileName: = FileBinPerevedenEdit. Text;//were already checked
FullPerevodFileName: = DirPerevodEdit. Text + PerevodFileNameEdit. Text;
FOriginal: = TFileStream. Create (FullOriginalFileName, fmOpenRead, fmShareDenyNone);
FPereveden: = TFileStream. Create (FullPerevedenFileName, fmOpenRead, fmShareDenyNone);
SizeOriginal: = FOriginal. Size;
SizePereveden: = FPereveden. Size;
if SizeOriginal <> SizePereveden then
begin
ShowMessage (' Lengths of BIN-files are not equal! ' + #10#13 +
' Continuation of process of handling - Is impossible! ');
Exit;
end;
//we Define length of arrays TBytes
SetLength (BOriginal, SizeOriginal);
SetLength (BPereveden, SizePereveden);
//It is readable Both files in TBytes
FOriginal. ReadBuffer (BOriginal, SizeOriginal);
FPereveden. ReadBuffer (BPereveden, SizePereveden);
AddressFiles: = 0;
StartTime: = Now;//we Fix Start time
//===== Rose on the Beginning in Both files =====
i: = 0;
while AddressFiles <= SizeOriginal-1 do
begin
ISimvol: = BOriginal [i];
PSimvol: = BPereveden [i];
Inc (i);
Inc (AddressFiles);
//we Search for coincidence Zero byte
if (ISimvol=0) and (PSimvol=0) then
begin
//
end;
end;
finally
FOriginal. Free;
FPereveden. Free;
EndTime: = Now;//we Fix STOP time
DelayTime: = SecondSpan (EndTime, StartTime);//we Calculate PROCEDURE runtime
MainMemo. Lines. Add (' Test run of files in a mode "MemoryStream" is completed! ' + #13#10 +
' test Time = ' + FloatToStr (DelayTime) + ' sec ');
end;
end;

[/spoiler] Received time of a cycle - 0,08 seconds !!!!
It perhaps the Champion!.)))

Posts [ 51 to 75 of 108 ]

Pages Previous 1 2 3 4 5 Next

You must login or register to post a reply