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: Rik
Subject: [Octave-bug-tracker] [bug #60928] Performance of sort unexpectedly slow for DIM=2
Date: Mon, 16 Aug 2021 12:45:14 -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

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

Okay, the slowdown is entirely due to this piece of code


      for (octave_idx_type j = 0; j < iter; j++)
        {
          octave_idx_type offset = j;
          octave_idx_type offset2 = 0;

          while (offset >= stride)
            {
              offset -= stride;
              offset2++;
            }

          offset += offset2 * stride * ns;


For dimension 1, stride is 1 and offset = j will take the values 1 .. 125,000
for my benchmark data.  So for the last calculation, the code reduces to a
while loop that executes 125,000 times simply to increment offset2.

I assume that the original coder was trying to calculate


offset = floor (j / stride) * stride * ns;


in such a way as to avoid conversion to double and to avoid actual division
operation.  However, this is causing real problems.

    _______________________________________________________

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]