octave-maintainers
[Top][All Lists]
Advanced

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

Re: more graphics changes.


From: John W. Eaton
Subject: Re: more graphics changes.
Date: Thu, 15 Mar 2007 10:10:42 -0400

On 15-Mar-2007, Daniel J Sebald wrote:

| Built in functions are fast.  Consider:
| 
| octave:172> tt=cputime();  P_tmpdir(); cputime()-tt
| ans =  0.0010000
| 
| Very short.  Now using the M-file fullfile() things slow a bit:
| 
| octave:176> tt=cputime();  fullfile (P_tmpdir, "gpimageXXXXXX"); cputime()-tt 
| ans =  0.13198
| 
| There's not a lot inside fullfile(), but I guess the file has to be read in, 
| parsed, organized, etc.

Yes, but this should only happen once, so you should probably look at
the timings for the second and later calls.  Also, .m file timestemp
checking should happen at most once per interactive prompt, so you
might also look at the difference between

  tt=cputime(); fullfile (P_tmpdir, "gpimageXXXXXX"); cputime()-tt

and

  tt=cputime(); ...
  fullfile (P_tmpdir, "gpimageXXXXXX"); ...
  fullfile (P_tmpdir, "gpimageXXXXXX"); ...
  [...say 10 or 20 times...]
  fullfile (P_tmpdir, "gpimageXXXXXX"); ...
  cputime()-tt

On my system, a single call takes about .02 seconds and 10 calls takes
about .028 seconds.

Since fullfile is called from inside Octave's PKG_ADD files, you might
have trouble getting timings for the initial call to it.

| I do find something odd about cputime().  Consider the following:
| 
| octave:204> [tt,tu,ts]=cputime(); image; [tt2,tu2,ts2]=cputime(); 
| [tt2,tu2,ts2]-[tt,tu,ts]
| ans =
| 
|     0.55092   0.44993   0.10098
| 
| You'd think that it has taken 0.5 s cputime to send an image to
| gnuplot.

That is also a lot of system time.  I'd guess that a lot of that is
spent doing fwrite because of the current inefficient (but I think
correct) implementation of fwrite in Octave.

| OK, well this would suggest one should use a good scripting strategy
| that avoids function calls as much as possible.  There is no need to
| keep checking whether one has a newer gnuplot version after the
| first time.  So, I'd think something like
| 
|      global __got_gnuplot_version__ = 0;
|      global have_newer_gnuplot;
| tx=cputime();
|      if (! __got_gnuplot_version__)
|        have_newer_gnuplot = compare_versions (__gnuplot_version__ (), "4.0", 
">");
|        __got_gnuplot_version__ = 1;
|      endif
| cputime()-tx
| 
| would save time, and in fact it does noticeably.

OK, I made this change, but I just used

  persistent have_newer_gnuplot ...
    = compare_versions (__gnuplot_version__ (), "4.0", ">");

in the places where it is needed.  I think that's good enough.

Thanks,

jwe


reply via email to

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