[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #65060] classdef: extremely slow writing to ar
From: |
A.R. Burgers |
Subject: |
[Octave-bug-tracker] [bug #65060] classdef: extremely slow writing to array properties |
Date: |
Wed, 20 Dec 2023 07:38:56 -0500 (EST) |
URL:
<https://savannah.gnu.org/bugs/?65060>
Summary: classdef: extremely slow writing to array properties
Group: GNU Octave
Submitter: arb
Submitted: Wed 20 Dec 2023 12:38:50 PM UTC
Category: Interpreter
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Performance
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Release: dev
Discussion Lock: Any
Operating System: Any
Fixed Release: None
Planned Release: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Wed 20 Dec 2023 12:38:50 PM UTC By: A.R. Burgers <arb>
Assigning to array classdef properties can be painfully slow.
Consider this class:
classdef foo
properties
data_s = [];
data_d = [];
end
end
and this script to exercise the class:
nrep = 2000;
dims = [2000, 2, 20300];
fi = foo;
fi.data_s = zeros(dims, 'single');
fi.data_d = zeros(dims, 'double');
data_s = zeros(dims, 'single');
data_d = zeros(dims, 'single');
dat_set = rand(dims(1), dims(2));
tic;
for i = 1 : min(nrep, dims(3))
data_d(:, :, i) = dat_set;
end
fprintf('Time for assign to double precision array: %g\n', toc);
tic;
for i = 1 : min(nrep, dims(3))
data_s(:, :, i) = dat_set;
end
fprintf('Time for assign to single precision array: %g\n', toc);
tic;
for i = 1 : min(nrep, dims(3))
foo.data_d(:, :, i) = dat_set;
end
fprintf('Time for assign to double precision property: %g\n', toc);
tic;
for i = 1 : min(nrep, dims(3))
foo.data_s(:, :, i) = dat_set;
end
fprintf('Time for assign to single precision property: %g\n', toc);
octave 10 timings:
Time for assign to double precision array: 0.0131512
Time for assign to single precision array: 0.0130341
Time for assign to double precision property: 52.545
Time for assign to single precision property: 29.0633
matlab R2019b timings
Time for assign to double precision array: 0.036111
Time for assign to single precision array: 0.033317
Time for assign to double precision property: 0.012477
Time for assign to single precision property: 0.042348
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Wed 20 Dec 2023 12:38:50 PM UTC Name: u_foo.m Size: 772B By: arb
<http://savannah.gnu.org/bugs/download.php?file_id=55468>
-------------------------------------------------------
Date: Wed 20 Dec 2023 12:38:50 PM UTC Name: foo.m Size: 70B By: arb
<http://savannah.gnu.org/bugs/download.php?file_id=55469>
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?65060>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #65060] classdef: extremely slow writing to array properties,
A.R. Burgers <=