Page 1 of 1

The extent to which the progress bar slows down the process

Posted: Fri Jan 13, 2017 10:42 pm
by Eugene Lutsenko
The extent to which the progress bar slows down the process?

I had the impression that the progress bar DC_GetProgress() is much stronger slows down the process than waiting DC_WaitOn()

Re: The extent to which the progress bar slows down the proc

Posted: Sat Jan 14, 2017 10:12 am
by rdonnay
Yes, it will slow down the process because writing to the screen is slow.

This is why you should use the EVERY clause.

Re: The extent to which the progress bar slows down the proc

Posted: Sat Jan 14, 2017 10:15 am
by Auge_Ohr
Eugene Lutsenko wrote:I had the impression that the progress bar DC_GetProgress() is much stronger slows down the process than waiting DC_WaitOn()
how do you use it ?
DC_WaitOn() is using a Thread.

Re: The extent to which the progress bar slows down the proc

Posted: Sun Jan 15, 2017 11:29 am
by Eugene Lutsenko
It turns out that special is no difference

Code: Select all

***********************************************************************************************************************
   mN = 1000
   @1+0.2,12 DCSAY "Задайте значение N:"       
   @2    ,27 DCSAY "" GET mN PICTURE "#######"

   DCGETOPTIONS TABSTOP
   DCREAD GUI ;
      FIT ;
      OPTIONS GetOptions ;
      ADDBUTTONS;
      MODAL ;
      TITLE '(C) Луценко Е.В. Измерение времени исполнения'
***********************************************************************************************************************

   aMess := {}

   nSeconds1 := Seconds()

   nMax  = mN
   Mess = 'Цикл от 1 до N='+ALLTRIM(STR(mN))
   @ 4,5 DCPROGRESS oProgress SIZE 70,1.1 MAXCOUNT nMax COLOR GRA_CLR_CYAN PERCENT EVERY 100
   DCREAD GUI TITLE Mess PARENT @oDialog FIT EXIT
   oDialog:show()

   nTime = 0

   DC_GetProgress(oProgress,0,nMax)
   FOR j = 1 TO mN
       s = 0
       FOR i=1 TO j
           s = s + i
       NEXT
       DC_GetProgress(oProgress, ++nTime, nMax)
   NEXT

   DC_GetProgress(oProgress,nMax,nMax)
   oDialog:Destroy()

   AADD(aMess, 'На расчет c DC_GetProgress затрачено: '+Alltrim(Str(Seconds()-nSeconds1,15,7)) + ' секунд')

**************************************************

   nSeconds2 := Seconds()

   oScrn := DC_WaitOn('Немного подождите')     
   FOR j = 1 TO mN
       s = 0
       FOR i=1 TO j
           s = s + i
       NEXT
   NEXT
   DC_Impl(oScrn)                                                   

   AADD(aMess, 'На расчет с DC_WaitOn        затрачено: '+Alltrim(Str(Seconds()-nSeconds2,15,7)) + ' секунд')

   LB_Warning( aMess )
[/size]

Re: The extent to which the progress bar slows down the proc

Posted: Sun Jan 15, 2017 1:09 pm
by Auge_Ohr
Eugene Lutsenko wrote:It turns out that special is no difference

Code: Select all

   mN = 1000
   ...
   @ 4,5 DCPROGRESS oProgress SIZE 70,1.1 MAXCOUNT nMax COLOR GRA_CLR_CYAN PERCENT EVERY 100
with mN := 1000 and EVERY 100 you got 10 Steps ...
use much bigger Number like nM := 1000000 to get Time Difference

Re: The extent to which the progress bar slows down the proc

Posted: Sun Jan 15, 2017 1:45 pm
by Eugene Lutsenko
Auge_Ohr wrote:
Eugene Lutsenko wrote:It turns out that special is no difference

Code: Select all

   mN = 1000
   ...
   @ 4,5 DCPROGRESS oProgress SIZE 70,1.1 MAXCOUNT nMax COLOR GRA_CLR_CYAN PERCENT EVERY 100
with mN := 1000 and EVERY 100 you got 10 Steps ...
use much bigger Number like nM := 1000000 to get Time Difference
I understand and noticed, it was tested on much larger quantities, such as 10,000. The program is attached there. You can try. But it turns out there is a noticeable difference, and the unexpected in small quantities. And at large there is practically no difference.

Re: The extent to which the progress bar slows down the proc

Posted: Sun Jan 15, 2017 3:49 pm
by Auge_Ohr
Eugene Lutsenko wrote:I understand and noticed, it was tested on much larger quantities, such as 10,000.
much more while 10,000/100 = 100 step to "paint" is just a blink
Eugene Lutsenko wrote:The program is attached there. You can try. But it turns out there is a noticeable difference, and the unexpected in small quantities. And at large there is practically no difference.
your Demo still have "fix" EVERY 100 so it only make 1000/100 = 10 Step

with 1000000 it make a lot of (unneed) step ... you only need

Code: Select all

   nEvery := nMax / 100
   ... EVERY nEvery
about compare with DC_WaitOn()

as it use a Thread, which you have to Stop with DC_Impl(), you calculation is the same as above
with small Number you have to know what Thread is doing

Code: Select all

FUNCTION dc_waiton (
      ...
      oThread:Start({||_Working(@oDlg)})

STATIC FUNCTION _Working( oDlg )
   ...
   DO WHILE Valtype(oDlg) = 'O' .AND. oDlg:cargo[2] .AND. oDlg:status() > 0
      ...
      Sleep(20) // <- fix
so DC_WaitOn() can differ in -+20 -> 40ms

Re: The extent to which the progress bar slows down the proc

Posted: Mon Jan 16, 2017 8:30 am
by Cliff Wiernik
I usually compute my nEvery so it only updates when the percentage completion changes by 1 or 5. So for 200000 records, every 200000/100 = 2000 records or for every 5%, 200000/20= 10000 records.