[bug #68091] Inefficient Integer Data Loading from MAT-Files

foreverallama <[email protected]> Thu, 16 Apr 2026 14:01:31 -0400 (EDT)
Newsgroups gmane.comp.gnu.octave.bugs
Message-ID <[email protected]>
Please use the bug tracker to post updates to a bug report.  The mailing list is intended as a read-only notification stream.  Info posted to this mailing list address won't appear in the tracker database where it is most useful.

Follow-up Comment #11, bug #68091 (group octave):

Sorry, been a while. Got back into it today, and putting a patch up that
incorporates the changes we were looking into then. 

I used "type_traits" with "if constexpr" for compile-time dispatch instead of
the macro. If the destination type and storage type match, that path should be
handled at compile time. We don't need to handle byte swap separately for
int8/uint8, it's already handled in "swap_bytes ()". Tests passed successfully
with "test/io.tst".

I don't believe we can remove the switch-case entirely, as we still need to
dispatch based on storage type which is known only at runtime. Hence, the main
change would be in removing the macro.

Some timing measures of performance below:

% Before Patch
octave:1> tic; load("large_int_arr.mat"); toc
Elapsed time is 0.296586 seconds.
octave:2> tic; load("large_object.mat"); toc
Elapsed time is 5.08949 seconds.

% After Patch
octave:1> tic; load("large_int_arr.mat"); toc
Elapsed time is 0.102456 seconds.
octave:2> tic; load("large_object.mat"); toc
Elapsed time is 2.84395 seconds.

% "large_int_arr" is a 3000x3000 uint8 array.
% "large_object" is an object instance of "ExampleClass" with a single
property "a" = 3000x3000 double.


Let me know what you think.

(file #58477)

    _______________________________________________________

Additional Item Attachment:

Name: bug68091.patch                 Size: 4.2KiB
    <https://file.savannah.gnu.org/file/bug68091.patch?file_id=58477>


    AGPL NOTICE

These attachments are served by Savane. You can download the corresponding
source code of Savane at
https://savannah.gnu.org/source/savane-f290f6b25beb8cb99bbe243a6cd2c5fef79ffcde.tar.gz


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68091>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCaeEj+wAKCRCqLAuaBUf3
Tqh+AQCcI9cG+yi/mCl36GVqDNWT1OGLvsjziYGG4EyRw8TU/gEA8M+rq0EmgaiP
dIyO39DVr8jwoWg7rpPR34rmAZCF/Qc=
=7zGy
-----END PGP SIGNATURE-----