How does the compression of MAT-files in MATLAB 7.0 (R14) affect performance?
32 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2012 年 9 月 5 日
編集済み: MathWorks Support Team
2016 年 11 月 18 日
I understand that MAT-files in MATLAB 7.0 (R14) are compressed by default. I would like to know how that affects performance.
採用された回答
MathWorks Support Team
2016 年 11 月 18 日
Following are some important things to note about compressed MAT-files :
1. You should consider both data set size and the type of data being saved when deciding whether or not to compress the data you save to a file. The benefits of data compression are greater when saving large data sets (over 3MB), and are usually negligible with smaller data sets. Data that has repeating patterns or more consistent values compresses better than random data. Compressing data that has a random pattern is not recommended as it slows down the performance of save and load significantly, and offers little benefit in return.
In general, data compression and decompression slows down all save and some load operations to some extent. In most cases, however, the resulting reduction in file size is worth the additional time spent compressing or decompressing. Because loading is typically done more frequently than saving, load is considered to be the more critical of the two operations. Up to a certain threshold (relative to the size of the uncompressed MAT-file), loading a compressed MAT-File is slightly slower than loading an uncompressed file containing the same data. Beyond that threshold, however, loading the compressed file is faster.
For example, say that you have a block of data that takes up 100 MB in memory, and this data has been saved to both a 10 MB compressed file and a 100 MB uncompressed file. When you load each of these files back into the MATLAB workspace, the first 10 MB of data takes the same amount of time to load for each file. Loading the remaining 90 MB from the uncompressed file will take 9 times as long as the first 10 MB, while all that remains to be done with the compressed file is to decompress the data, and this takes a relatively short amount of time.
The loading size threshold is lower for network files, and also varies depending on the type of computer being used. Network users loading compressed MAT-files gemerally see faster load times than when loading uncompressed files, and at smaller data sizes than users loading the same files locally.
2. Given the wide range of possible combinations of variable sizes, data types, and the number of variables that may be saved to an MAT-file, we don't have statistics on MAT-file performance. To determine whether compression has an affect on your code's performance, you can run the actual application under MATLAB 7.0 (R14) with compression turned on, and turned off.
3. In MATLAB Versions 7.0 through 7.2, you could use the switches –compress, –nocompress, –unicode, and –nounicode with the save function to enable or disable compression and Unicode character encoding in the MAT-file being generated. In MATLAB Version 7.3, the save function no longer supports these switches. Instead, save now creates a MAT-file with compression and Unicode character encoding by default, or with the following command:
save -v7 filename
You can still save to a MAT-file without using compression or Unicode encoding. In fact, you will have to do this in order to create MAT-files that you can load into a MATLAB Version 6 or earlier. To save to a MAT-file without compression or Unicode encoding, type
save -v6 filename
To disable compression and Unicode encoding for all save operations in a MATLAB session, open the MATLAB Preferences dialog, select General and then MAT-Files, and then click the button labelled Ensure backward compatibility (-v6).
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File 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!