Fastest way to load data.
조회 수: 77 (최근 30일)
이전 댓글 표시
Hello,
I have an array of size ~320 Mb that I want to store in a file such that the loading afterwards is as fast as possible.
Currently simply doing:
save('filename.mat', 'var');
takes around 2.4 seconds.
What flags (if any) can I give the save() or load() functions that can achieve this?
Currently on saving as .mat file using the '-v6' flag (file size now 470Mb) has allowed me to get the load time down to 0.14 seconds!
Are there things I can leverage to reduce this further?
My SSDs read and write speeds are ~1.4 GB/s
댓글 수: 0
답변 (1개)
dpb
2023년 8월 16일
편집: dpb
2023년 8월 16일
save does compression by default now which takes time as you've discovered.
The absolute fastest albeit somewhat less convenient should be using fwrite, fread as far as pure i/o speed.
fid=fopen('filename.bin','w');
fwrite(fid,var)
fid=fclose(fid);
One test here was almost a tie, however, so likely not sufficiently faster to be worth the effort.
The way to speed it up if you can afford to lose some precision would be to only use single-precision instead of double...half as many bytes to read/write. It won't be a full 2X gain because memory access will be just a tad quicker for 8-byte rather than 4-byte increments probably, but should be observeable speedup. Of course, if you need to preserve full precision this isn't an option.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Direct Search에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!