Recent

Author Topic: Get the required time to load huge amount of files  (Read 3434 times)

Sora-Kun

  • Full Member
  • ***
  • Posts: 162
  • I can smell your presence ...
    • Sora-Kun
Get the required time to load huge amount of files
« on: March 30, 2012, 04:18:23 pm »
Hello,
   I am making an IDE, and had the idea to load about 2964 files. The IDE took very long time loading them, so I had the idea to show the user the remaining time till the files get totally loaded.
Any way to do that ?

 %)
if nothing suites you, make it your self!
The Revolution, Genesis. The next generation IDE.
If you want to help, PM me.

Made in Lazarus.
Soon, in The WWW.

garlar27

  • Hero Member
  • *****
  • Posts: 652
Re: Get the required time to load huge amount of files
« Reply #1 on: March 30, 2012, 04:29:46 pm »
You can use a TProgressBar:
Code: [Select]
//...
for i := 0 to FileCounter do begin
   LoadOneFileHere(AFileName);
   ProgressBar1.StepIt;
   Application.ProcessMessages;// to refresh tthe screen
end;

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Get the required time to load huge amount of files
« Reply #2 on: March 30, 2012, 05:11:40 pm »
Additionally, you can display an estimated time on extrapolating the time spent so far:

Code: [Select]
var i:integer;
  dt:TDateTime;

begin
  dt:=now;
  ProgressBar1.Min:=0;
  ProgressBar1.Max:=filecount;
  ProgressBar1.Step:=1;
  for i := 1 to filecount do begin
   LoadOneFileHere(AFileName);
   ProgressBar1.StepIt;
   if i mod 10 =5 then
     Label1.Caption:=IntToStr(round((filecount-i)*((now-dt)* 24*60*60 ) / i ))+' secs remaining' ;
   Application.ProcessMessages;// to refresh tthe screen
  end;
  Label1.Caption:='Finished';

end;
This displays in label1 the seconds remaining to complete the task. It is updated every 10 files (i mod 10). It starts with the fifth file to have a minimum of data to extrapolate with.

Sora-Kun

  • Full Member
  • ***
  • Posts: 162
  • I can smell your presence ...
    • Sora-Kun
Re: Get the required time to load huge amount of files
« Reply #3 on: March 31, 2012, 03:10:53 pm »
Hello,

Thank you very much ! in combination of your two idea, i made a very nice loading window, which show well detailed loading informations !
if nothing suites you, make it your self!
The Revolution, Genesis. The next generation IDE.
If you want to help, PM me.

Made in Lazarus.
Soon, in The WWW.

 

TinyPortal © 2005-2018