[MSEide-MSEgui-talk] Tprogressbar and resource used ?

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

[MSEide-MSEgui-talk] Tprogressbar and resource used ?

fredvs
Hello Martin.

I am a little afraid about the resource used by tprogressbar.

Included a simple demo to show it.
msemem.zip
<http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/msemem.zip>  

The tprogressbar.value is assigned by a timer with a random value:

When rendering the tprogressbar: cpu used = 70 %.

<http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/mse_progressbar_on.png>

Without rendering the tprogressbar, cpu used = 28 %.

<http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/mse_progressbar_off.png>

Is there a other-less-resource-used way to mimic a  tprogressbar ?
Do you think that drawing on a custom canvas would need less resource ?

Thanks.

Fre;D




--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Tprogressbar and resource used ?

mse
Administrator
On Friday 01 June 2018 14:45:41 fredvs wrote:

> Hello Martin.
>
> I am a little afraid about the resource used by tprogressbar.
>
> Included a simple demo to show it.
> msemem.zip
> <http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/msemem.zip>
>
> The tprogressbar.value is assigned by a timer with a random value:
>
> When rendering the tprogressbar: cpu used = 70 %.
>
I get 2% for msemem and 4% for Xorg, see attachment.

Some optimizations:
"
procedure tmainfo.ontimerwait(const Sender: TObject);
var
 i : int32 = 1;
 f : float ;

begin
  timerwait.Enabled := False; //<<<<not necessary

 if tag = 0 then begin  
  while i < 21 do
  begin
  f := random(100)/100;  //<<<< FPC random is slow
  tlabel1.caption := ' Random number = ' + floattostr(f);
 
  if enableview.value = true then
   TProgressBar(findcomponent('tprogressbar'+inttostr(i))).value:= f else
                     //<<<<<<< findcomponent is slow
   TProgressBar(findcomponent('tprogressbar'+inttostr(i))).value:= 0;    
  inc(i);
  end;
  timerwait.Enabled := true;  //<<<<not necessary
 
end;
end;
"
Removing the fades probably also speeds up things.

> <http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/mse_progressbar_on.p
>ng>
>
> Without rendering the tprogressbar, cpu used = 28 %.
>
> <http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/mse_progressbar_off.
>png>
>
> Is there a other-less-resource-used way to mimic a  tprogressbar ?

A tchart with traces[0].chartkind = tck_bar probably is faster because it is a
single widget instead of 20 tprogressbar.
"
procedure tmainfo.timerevent(const sender: TObject);
var
 ar1: flo64arty;
 i1: int32;
begin
 setlength(ar1,20);
 for i1:= 0 to high(ar1) do begin
  ar1[i1]:= mwcnoise() / flo64($ffffffff);
 end;
 bar.traces[0].ydata:= ar1;
end;
"
mwcnoise() is from unit msenoise.

> Do you think that drawing on a custom canvas would need less resource ?
>
Probably.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

bars.png (89K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Tprogressbar and resource used ?

fredvs
Hello Martin.

> Removing the fades probably also speeds up things.

Yes, it is what I want to show you.
Removing the fades makes use only 35 % of resource.

<http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/mse_progressbar_on_nofade.png>

But I will study your answer, write you later.

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Tprogressbar and resource used ?

fredvs
This post was updated on .
Hello Martin.

Ok, I did test Tchart vs TProgressbar.

My verdict is:

- If TProgressbar does not have fading and frame is original (not use a
template) and not = nil (only a "pure" <tcaptionframe>) then the ressource
used by 20 TProgressbars is more or less equal than ressource used by 1
TChart of 20 bars.

- If TProgressbar use fading or frame is custom ===> much more ressource
used than a Tchart.

Some questions:

What is mwcnoise() / flo64($ffffffff) ?
Is it a alternative to random() ?

Here updated demo that uses both TProgressbar and/or Tchart.

msemem.zip
<http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/msemem.zip

Thanks.

Fre;D







--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Tprogressbar and resource used ?

fredvs
> Is it possible to have a TChart with only verticals bars (not linked like
in
> demo) that mimic a TProgressbar ?

Ha, ok, ---> charkind := tck_bar.

Thanks.

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Tprogressbar and resource used ?

mse
Administrator
In reply to this post by fredvs
On Saturday 02 June 2018 16:26:58 fredvs wrote:
>
> Some questions:
>
> What is mwcnoise() / flo64($ffffffff) ?
> Is it a alternative to random() ?
>
Yes, it is much faster but its statistical quality is lower than the mersenne
twister of FPC.

> Is it possible to have a TChart with only verticals bars (not linked like
> in demo) that mimic a TProgressbar ?
>
Set traces.chartkind to tck_bar. The bar settings are in traces[n].bar_*.
BTW, traces.count should be 1.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Tprogressbar and resource used ?

fredvs
In reply to this post by fredvs
Hello Marin.

How to fit all the bars in a TChart ?

On the picture, you may see that last bar is missing.
Changing for bigger tchart.width did not solve.

<http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/mse_tchart_fit.png>

Included demo of this.

msemem.zip
<http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/msemem.zip>  

Thanks.

Fre;D

PS: Indeed, Tchart uses less resource.




--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Tprogressbar and resource used ?

mse
Administrator
On Saturday 02 June 2018 20:53:56 fredvs wrote:
> Hello Marin.
>
> How to fit all the bars in a TChart ?
>
Set traces.xserrange to 0.9, xserstart to 0.05. Set traces[0].offset to -10.

Please do not set traces.count to 20.
"
procedure tmainfo.oncreated(const sender: TObject);
begin
 Timerwait := ttimer.Create(nil);
  Timerwait.interval := 20000;
  Timerwait.Enabled := False;
  Timerwait.ontimer := @ontimerwait;
  setlength(ar1,20);
 
//  tchart1.traces.count := 20; <<<---!!!!!!
 
end;
"

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Tprogressbar and resource used ?

fredvs
Hello Martin.

> Please do not set traces.count to 20

Ha, ok. I did use:

  tchart.traces.count := 20;
  tchart.traces.maxcount :=  tchart.traces.count + 1;

And with this I get a perfect result.

<http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/msetchart.png>

But, ok, I will study your code.

Thanks.

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Tprogressbar and resource used ?

fredvs
In reply to this post by mse
> Set traces.xserrange to 0.9, xserstart to 0.05. Set traces[0].offset to -10

Ooops, I have to buy a bigger cristal ball because mine did not show that.

OK but very tricky.

( Would it be a horrible crime to use:
  tchart.traces.count := 20;
  tchart.traces.maxcount :=  tchart.traces.count + 1; )

Thanks.

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Tprogressbar and resource used ?

mse
Administrator
In reply to this post by fredvs
On Sunday 03 June 2018 13:49:57 fredvs wrote:
> Hello Martin.
>
> > Please do not set traces.count to 20
>
> Ha, ok. I did use:
>
>   tchart.traces.count := 20;

That means you create additional trace items traces[1..19] which do nothing
other than to consume RAM and CPU cycles.

>   tchart.traces.maxcount :=  tchart.traces.count + 1;
>
This is the default value of tchart.traces[n].maxcount which limits the number
of displayed xseries values = ydata = the number of bars.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Tprogressbar and resource used ?

mse
Administrator
In reply to this post by fredvs
On Sunday 03 June 2018 14:09:07 fredvs wrote:
> > Set traces.xserrange to 0.9, xserstart to 0.05. Set traces[0].offset to
> > -10
>
> Ooops, I have to buy a bigger cristal ball because mine did not show that.
>
The whole tchart works with scales. It is no collection of progressbars. ;-)

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk