필터 지우기
필터 지우기

Why is partial loading of matfile "inefficient" for -v7, but still faster?

조회 수: 3 (최근 30일)
When executing the following code, I get a warning that partial loading the -v7 *.mat file is "inefficient" and am told to use -v7.3 instead. However, when I test the execution times of each, it is actually the -v7 file which is faster. Why is this? To what "inefficiencies" does the warning refer?
>> whos
Name Size Bytes Class
b 1x1 8 double
c 641x143 366652 uint32
d 1x143 19296 cell
e 1x1 128 cell
>> save('G:\deletme0.mat','b','c','d','e')
>> save('G:\deletme1.mat','b','c','d','e','-v7.3')
>> save('G:\deletme2.mat','b','c','d','e','-v7.3','-nocompression')
>> tic; m = matfile('G:\deletme0.mat'); q = m.c(1:10,1:50); toc
Warning: The file 'G:\deletme0.mat' was saved in a format that does not support partial loading. Temporarily loading variable 'c' into memory. To use partial loading efficiently, save MAT-files with the -v7.3 flag. > In matlab.io.MatFile/inefficientPartialLoad (line 144) In matlab.io.MatFile/subsref (line 462)
Elapsed time is 0.009319 seconds.
>> tic; m = matfile('G:\deletme1.mat'); q = m.c(1:10,1:50); toc
Elapsed time is 0.013688 seconds.
>> tic; m = matfile('G:\deletme2.mat'); q = m.c(1:10,1:50); toc
Elapsed time is 0.013699 seconds.

채택된 답변

Philip Borghesani
Philip Borghesani 2017년 3월 23일
V7 matfiles are faster in general and can be much faster if many small structures are saved. When working with large files containing large variables V7.3 files can be partially loaded reducing time and memory while the entire V7 file must be loaded to extract any variable.
You might see different results if the sizes of c and d were in the millions.
  댓글 수: 1
Joseph Hall
Joseph Hall 2017년 3월 23일
편집: Joseph Hall 2017년 3월 23일
Thank you. Below shows a quick test which confirms your suggestion that -v7.3 files can be more efficient/faster than -v7 when partial-loading a larger size matrix.
>> a = zeros(1e6,50);
>> whos a
Name Size Bytes Class Attributes
a 1000000x50 400000000 double
>> save('G:\deletme0.mat','a','-v7')
>> save('G:\deletme1.mat','a','-v7.3')
>> save('G:\deletme2.mat','a','-v7.3','-nocompression')
>> tic; m = matfile('G:\deletme0.mat'); q = m.a(1:10,1:50); toc
Warning: The file 'G:\deletme0.mat' was saved in a format that does not
support partial loading. Temporarily loading variable 'a' into memory. To use
partial loading efficiently, save MAT-files with the -v7.3 flag.
> In matlab.io.MatFile/inefficientPartialLoad (line 144)
In matlab.io.MatFile/subsref (line 462)
Elapsed time is 0.228414 seconds.
>> tic; m = matfile('G:\deletme1.mat'); q = m.a(1:10,1:50); toc
Elapsed time is 0.006759 seconds.
>> tic; m = matfile('G:\deletme2.mat'); q = m.a(1:10,1:50); toc
Elapsed time is 0.036743 seconds.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by