From maintainers-request at octave dot org Sun Jan 30 01:39:59 2005 Subject: Re: min function very slow? From: Daniel J Sebald To: maintainers at octave dot org Date: Sun, 30 Jan 2005 01:46:03 -0600 Daniel J Sebald wrote: > John W. Eaton wrote: > >> If you have min and max in .oct files, then they are really defined in >> the same file (minmax.oct) and the min.oct and max.oct files are just >> additional links in the filesystem. It seems that the second one >> loaded is much slower. I think this must be some accidental overhead >> in checking whether the symbol needs to be reloaded. >> > > But how would this account for Dmitri's example in a script file where > upon first run it's fine and thereafter is slow? > >> The problem goes >> away for me if I define min and max in separate files (i.e., create >> min.cc and max.cc, each with only one DEFUN_DLD macro) or if I set >> ignore_function_time_stamp = "all" (I'm not sure why setting it to >> "system" fails, even when the min/max functions are installed in a >> "system" directory). >> >> > > But breaking it into separate files could simply be shuffling around > code as well. I.e., the problem moves somewhere else. On second thought, your hypothesis seems correct. rand() and randn() are similar to max/min, being in the same file. I rewrote the function with rand/randn and got similar behavior: octave:1> [loopt, randt, randnt] = rrt(10000) loopt = 0.10696 randt = 0.36079 randnt = 0.35501 octave:2> [loopt, randt, randnt] = rrt(10000) loopt = 0.10461 randt = 0.34843 randnt = 7.3243