From maintainers-request at octave dot org Sun Jan 30 01:07:33 2005 Subject: Re: min function very slow? From: Daniel J Sebald To: "Dmitri A. Sergatskov" Cc: maintainers at octave dot org Date: Sun, 30 Jan 2005 01:13:46 -0600 Dmitri A. Sergatskov wrote: > Daniel J Sebald wrote: > >> Dmitri A. Sergatskov wrote: >> >>> Daniel J Sebald wrote: >>> >>>> >>>> >>>> Thank you... so do you think your increase for mintime is a blip in >>>> the OS? Yours is a factor of 4.5 difference, mine is a factor of 76. >>>> >>> >>> I do not understand this at all. More over on my other computer >>> (AthlonXP 1666 MHz) >>> the mintime is 2 seconds... The same OS etc... >> >> >> >> >> So I'm not dreaming. :-) >> >> I put a script in my path to redefine min(x) as -max(-x). That gets >> me down to the numbers your quoting. I'll see if I can run a >> profiler on this. I don't think it is in dNDArray.cc where it is >> spending its time. >> > > I rewrote your script as a function (attached). Here is some numbers: > > octave:1> [loopt,mint,maxt]=mmt(10000) > loopt = 0.040803 > mint = 0.19301 > maxt = 0.22110 > octave:2> [loopt,mint,maxt]=mmt(10000) > loopt = 0.031585 > mint = 0.18326 > maxt = 23.859 > octave:3> [loopt,mint,maxt]=mmt(10000) > loopt = 0.039405 > mint = 0.18089 > maxt = 22.695 > > On SMP computer (octave compiled with -lpthread, otherwise the same > flags): > > octave:1> [loopt,mint,maxt]=mmt(10000) > loopt = 0.033668 > mint = 0.15524 > maxt = 0.18152 > octave:2> [loopt,mint,maxt]=mmt(10000) > loopt = 0.026402 > mint = 0.14753 > maxt = 2.6565 > > As you can see the first time it runs it gets reasonable numbers, > after that it goes nuts. Sure 'nough. (You've switched maxt and mint, but point taken.) Look at what I'm getting: octave:1> [loopt, maxt, mint] = mmt(10000) loopt = 0.10684 maxt = 0.50235 mint = 0.51636 octave:2> [loopt, maxt, mint] = mmt(10000) loopt = 0.087893 maxt = 0.47367 mint = 71.194 Everything in the code looks so symmetric with regard to min and max. Strange. Could a header file definition of "min" be substituting code that somehow still compiles? (Wild, wild guess.) Dan