SEARCH YOUR SOLUTION HERE  

Faster TFileStream



Do you now if TFileStream (FileWrite etc.)
uses an internal Windows memory buffer

If not, I will probably try write another stream class
that uses an internal memory buffer (one than can
grow, but never shrink) and then write-to-file once
in a while (clearing the internal memory buffer).

best regards
Thomas Schulz


Posted On: Tuesday 16th of October 2012 03:50:42 AM Total Views:  73
View Complete with Replies




Related Messages:

Is graphics32 Bitmap32 faster than TBitmap ?   (116 Views)
The following procedure with TBitmap is slow (pieces are slow moving) : (an image is read, divided into 20 pieces (faces) and each piece is distributed at random around the the form , if mode is > 0 than pieces are pivoted). Problem is that pieces are slowly displaced around the edge of the form. (about 10 sec. for 20 pieces) Can Graphics32 be of any help - or the actual procedure should be optimized ------------------------ procedure TForm1.SBt_MelangeClick(Sender: TObject); var i,n,s,lg,cl : byte; begin SBt_Images.Enabled := False; if not bopen then exit; LitUneImage(tbPima[aface]); // see LitUneImage Procedure down below Imodele.Picture.Bitmap := Image; // a jpg image Imodele.Visible := false; for lg := 1 to 4 do for cl := 1 to 5 do tbCube[lg,cl].AfficheUneFace(aface); // tbCube : array[1..4,1..5] of TCube; see down below for i := 1 to 20 do tbdes[i] := i; for i := 1 to 20 do // place for each cube begin // distribution of the pieces around the form n := Random(20)+1; s := tbdes[n]; tbdes[n] := tbdes[i]; tbdes[i] := s; end; for lg := 1 to 4 do // random face for each cube for cl := 1 to 5 do // move the cubes on the sides begin if modjeu > 1 then begin tbCube[lg,cl].Virtuel := false; end else tbCube[lg,cl].Virtuel := true; if modjeu > 0 then // note: ---------- pieces are slow moving even if modjeu 0 tbCube[lg,cl].AfficheUneFace(Random(6)); DeplaceCube(lg,cl); if modjeu = 2 then tbCube[lg,cl].PivoteUneFace(Random(4)+1); end; end; -------- procedure LitUneImage(pima : TPima); var MemS : TMemoryStream; bima : TBitmap; begin ImaStrm.Position := pima.posima; MemS := TMemoryStream.Create; bima := TBitmap.Create; try MemS.SetSize(pima.taille); MemS.CopyFrom(ImaStrm,pima.taille); MemS.Position := 0; Jpgim.LoadFromStream(Mems); bima.Assign(Jpgim); BitmapRedim(bima,Image,ilg,iht,true); finally MemS.Free; bima.Free; end; end; ------------------------ procedure TCube.AfficheUneFace(Index : integer); begin Picture.Assign(fTabloBtm[Index]); fIndexFace := Index * 4; end;
Is graphics32 Bitmap32 faster than TBitmap ?   (139 Views)
The following procedure with TBitmap is slow (pieces are slow moving) : (an image is read, divided into 20 pieces (faces) and each piece is distributed at random around the the form , if mode is > 0 than pieces are pivoted). Problem is that pieces are slowly displaced around the edge of the form. (about 10 sec. for 20 pieces) Can Graphics32 be of any help - or the actual procedure should be optimized ------------------------ procedure TForm1.SBt_MelangeClick(Sender: TObject); var i,n,s,lg,cl : byte; begin SBt_Images.Enabled := False; if not bopen then exit; LitUneImage(tbPima[aface]); // see LitUneImage Procedure down below Imodele.Picture.Bitmap := Image; // a jpg image Imodele.Visible := false; for lg := 1 to 4 do for cl := 1 to 5 do tbCube[lg,cl].AfficheUneFace(aface); // tbCube : array[1..4,1..5] of TCube; see down below for i := 1 to 20 do tbdes[i] := i; for i := 1 to 20 do // place for each cube begin // distribution of the pieces around the form n := Random(20)+1; s := tbdes[n]; tbdes[n] := tbdes[i]; tbdes[i] := s; end; for lg := 1 to 4 do // random face for each cube for cl := 1 to 5 do // move the cubes on the sides begin if modjeu > 1 then begin tbCube[lg,cl].Virtuel := false; end else tbCube[lg,cl].Virtuel := true; if modjeu > 0 then // note: ---------- pieces are slow moving even if modjeu 0 tbCube[lg,cl].AfficheUneFace(Random(6)); DeplaceCube(lg,cl); if modjeu = 2 then tbCube[lg,cl].PivoteUneFace(Random(4)+1); end; end; -------- procedure LitUneImage(pima : TPima); var MemS : TMemoryStream; bima : TBitmap; begin ImaStrm.Position := pima.posima; MemS := TMemoryStream.Create; bima := TBitmap.Create; try MemS.SetSize(pima.taille); MemS.CopyFrom(ImaStrm,pima.taille); MemS.Position := 0; Jpgim.LoadFromStream(Mems); bima.Assign(Jpgim); BitmapRedim(bima,Image,ilg,iht,true); finally MemS.Free; bima.Free; end; end; ------------------------ procedure TCube.AfficheUneFace(Index : integer); begin Picture.Assign(fTabloBtm[Index]); fIndexFace := Index * 4; end;