octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #60928] Performance of sort unexpectedly slow


From: anonymous
Subject: [Octave-bug-tracker] [bug #60928] Performance of sort unexpectedly slow for DIM=2
Date: Sun, 18 Jul 2021 17:07:02 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0

Follow-up Comment #2, bug #60928 (project octave):

It seems to be made worse for arrays where size(foo,2) is small, even just 1,
and size(foo,3) is big.

Test code: 

function myfun (tmp)
  tic; sort (tmp,1); t1 = toc;
  tic; sort (tmp,2); t2 = toc;
  tic; sort (tmp,3); t3 = toc;
  disp ([t1 t2 t3])
endfunction

tmp = rand (1,2,1e5); myfun (tmp)
tmp = rand (1,1e5,2); myfun (tmp)
tmp = rand (2,1,1e5); myfun (tmp)
tmp = rand (2,1e5,1); myfun (tmp)
tmp = rand (1e5,1,2); myfun (tmp)
tmp = rand (1e5,2,1); myfun (tmp)

tmp = rand (1,2,5e5); myfun (tmp)
tmp = rand (1,5e5,2); myfun (tmp)
tmp = rand (2,1,5e5); myfun (tmp)
tmp = rand (2,5e5,1); myfun (tmp)
tmp = rand (5e5,1,2); myfun (tmp)
tmp = rand (5e5,2,1); myfun (tmp)


Everything takes only milliseconds or less, as expected, EXCEPT the case
sort(tmp,2) where tmp = rand (2,1,1e5) or tmp = rand(2,1,5e5) which are about
1500X and 7500X slower than the baseline. This is particularly pathological
because size(tmp,2) == 1, so it doesn't even need to do anything when asked
for sort(tmp,2) except return the argument as-is.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60928>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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