[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #58564] classdef instance field access painful
From: |
Neil Konzen |
Subject: |
[Octave-bug-tracker] [bug #58564] classdef instance field access painfully slow vs. struct field access |
Date: |
Mon, 15 Jun 2020 23:00:50 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36 |
Follow-up Comment #6, bug #58564 (project octave):
In Matlab, class .() access is quite a bit slower than struct .() access, but
thanks to the JIT class direct field access is as fast as for structs.
For reference, here are the Matlab timings on the same machine as the Octave
results I posted earlier. The direct field access times are essentially the
same, within the variance of the measurements.
.() access is
struct: obj.field access time = 0.025 usec
struct: obj.('field') access time = 0.643 usec
struct: subsref(obj,struct) access time = 5.836 usec
value_class: obj.field access time = 0.031 usec
value_class: obj.('field') access time = 1.972 usec
value_class: subsref(obj,struct) access time = 7.588 usec
handle_class: obj.field access time = 0.036 usec
handle_class: obj.('field') access time = 1.969 usec
handle_class: subsref(obj,struct) access time = 7.499 usec
You can see that Matlab's JIT is really pretty awesome. Class .() is quite a
bit slower than struct .(), roughly by the same factor of 3 that is seen in
the Octave results. I'll bet there are more dictionaries to search to handle
subclassing.
This lousy performance for direct field access, plus the fact that we still
can't set breakpoints in classdef code makes Octave a pretty impractical
platform for OO class development.
@apjanke I saw your stack overflow Q&A: nice! That's a pretty old thread,
it's probably worth the trouble to start a new question and answer for people
who are searching for perf info as I was. I almost overlooked your answer
updates when I saw it the first time.
The results you posted here are Octave results, right? It says Matlab in the
benchmark output; that's worth fixing.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?58564>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/