[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #53778] waitbar produces extra figure in 4.3.9

From: Dan Sebald
Subject: [Octave-bug-tracker] [bug #53778] waitbar produces extra figure in 4.3.91
Date: Sun, 29 Apr 2018 00:35:31 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0

Follow-up Comment #5, bug #53778 (project octave):


On the topic of time, I'm seeing:

>> tic; for i=1:10000; ishold(); endfor; toc
Elapsed time is 3.0081 seconds.
>> tic; fig = gcf(); for i=1:10000; ishold(fig); endfor; toc
Elapsed time is 3.11939 seconds.
>> tic; hax = gca(); for i=1:10000; ishold(hax); endfor; toc
Elapsed time is 8.5717 seconds.

So, not too much difference between using the gcf-input form compared agains
the no-input form.  However, the gca-input is almost three times slower.

I have a vague memory of either you or John speeding up some aspect of this. 
Maybe somewhere along the way a change decreased the drag due to ishold(hax). 
But still, why three times the CPU usage?  It's because of the use of
ancestor() script.  Code reuse is good practice, but sometimes code reuse ends
up repeating various tests like ishghandle() or isfigure() which can be costly
in an interpreted language.  The following is a step in reducing the CPU
consumption for ishold(hax):

diff --git a/scripts/plot/util/ishold.m b/scripts/plot/util/ishold.m
--- a/scripts/plot/util/ishold.m
+++ b/scripts/plot/util/ishold.m
@@ -49,7 +49,13 @@ function retval = ishold (h)
       case "axes"
         ax = h;
-        fig = ancestor (ax, "figure");
+        fig = h;
+        while (! isempty (fig))
+          fig = get (fig, "parent");
+          if (strcmp (get (fig, "type"), "figure"))
+            break;
+          endif
+        endwhile
         error ("ishold: H must be an axes or figure graphics handle");

With that change, I'm seeing:

>> tic; hax = gca(); for i=1:10000; ishold(hax); endfor; toc
Elapsed time is 4.22686 seconds.

which isn't too bad, 40% CPU cost.

Nontheless, in the grand scheme, that cost of using ishold(hax) vs. ishold()
may be small compared against whatever else is happening.  That is, the
graphics of the patch code may be a factor greater than the ishold(hax) cost.


Reply to this item at:


  Message sent via Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]