[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #60928] Performance of sort unexpectedly slow
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #60928] Performance of sort unexpectedly slow for DIM=2 |
Date: |
Sat, 17 Jul 2021 22:50:39 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36 |
Update of bug #60928 (project octave):
Status: None => Confirmed
Summary: Performance of sort, not sure if this is expected
behavior? => Performance of sort unexpectedly slow for DIM=2
_______________________________________________________
Follow-up Comment #1:
Confirmed. This is really odd behavior that seems to be limited to sorting
along the second dimension. I modified your test code to look at sorting
along each dimension.
data = rand (5,3,5e4);
tic; s2 = sort (data, 1); bm_sort = toc
#tic; s2 = sort (data, 2); bm_sort = toc
#tic; s2 = sort (data, 3); bm_sort = toc
perm = [1 2 3];
#perm = [2 1 3];
#perm = [3 2 1];
tic; s1 = ipermute (sort (permute (data, perm), 1), perm); bm_perm = toc
if (! isequal (s1, s2))
disp ("s1 != s2");
endif
Timings for sorting along dimension 1 are already strange.
bm_sort = 0.016349
bm_perm = 0.011381
In this case, the benchmark for the permute strategy has a call to permute(),
the exact same call to sort(), and a call to ipermute(). How can that take
less time then the single call to sort?
Timing for dimension 2 are the real issue.
bm_sort = 3.8263
bm_perm = 0.016575
The call to sort() is 231X slower than using the permute strategy.
Finally, sorting on dimension 3 seems about the same.
bm_sort = 0.085065
bm_perm = 0.072229
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?60928>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/