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

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

[Octave-bug-tracker] [bug #35400] Performance of in-place operations


From: Rik
Subject: [Octave-bug-tracker] [bug #35400] Performance of in-place operations
Date: Mon, 30 Jan 2012 01:45:08 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20100101 Firefox/5.0

URL:
  <http://savannah.gnu.org/bugs/?35400>

                 Summary: Performance of in-place operations
                 Project: GNU Octave
            Submitted by: rik5
            Submitted on: Sun 29 Jan 2012 05:45:07 PM PST
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Performance
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.6.0
        Operating System: GNU/Linux

    _______________________________________________________

Details:

The increment operation can be coded a number of different ways in Octave.


x = x + 1;
x++;
x += 1;


After benchmarking the operations, it turns out that the third form is
significantly faster (> 2X) than the others.  It is disconcerting to have the
performance depend so heavily on exactly what construct the coder uses.

The reason for the performance speed-up is the work done by Jaroslav which
means that the third case uses in-place accumulation rather than assigning to
a temporary array.

One possible solution would be to have the parser recognize the first two
forms as in-place operations and map to the existing code used in the third
form.  This issue applies to any of the operators which also have in-place
forms (+=, -=, *=, /=, &=, |=, ^=, etc.) 

I'm attaching a benchmark script I used (bm_accum.m).  The test results are:

x = x + 1;
Elapsed time is 1.7 seconds.
x++;
Elapsed time is 1.8 seconds.
x += 1;
Elapsed time is 0.69 seconds.





    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Sun 29 Jan 2012 05:45:07 PM PST  Name: bm_accum.m  Size: 147B   By: rik5

<http://savannah.gnu.org/bugs/download.php?file_id=24912>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?35400>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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