数据压缩率

🗜️ Data Compression Ratio

Compute the compression ratio and rate from original and compressed sizes to quantify compression effectiveness.

📐 计算公式与说明

压缩效果三卡:压缩率 = (1 − 压缩后字节 ÷ 原始字节) × 100%(保留 2 位小数)、压缩比 = 原始字节 ÷ 压缩后字节(×,保留 2 位小数)、总节省字节 = (原始 − 压缩后) × 文件数。校验:原始、压缩后、文件数三项非空守卫,数值非数按 0 兜底。判据:压缩率与压缩比同向联动(压缩率越接近 100% 压缩比越大),总节省随文件数线性放大。

压缩率越接近 100% 压缩越强。

📚 深度解析:数据压缩率

💡 常见使用场景

示例:100 MB → 30 MB
压缩率 = (1−30/100)×100% = 70%,压缩比 = 100/30 ≈ 3.33×。

❓ 常见问题(FAQ)

压缩率与压缩比区别?
压缩率=(1−压缩后/原始)×100% 表示节省比例;压缩比=原始/压缩后表示体积倍数。
为何有时越压越大?
已压缩或随机数据无冗余,加压缩头反而略增,属正常。
接近 100% 一定好吗?
压缩率越高越省空间,但需权衡 CPU 与耗时,实时场景未必划算。

Formula & Standard References

Item Formula / Rule Source / Standard
Compression ratio Ratio = original bytes ÷ compressed bytes RFC 1951 DEFLATE Compressed Data Format Specification
Space saving Saving = (original − compressed) ÷ original × 100% RFC 1952 GZIP File Format Specification §2
Lossless lower bound Average code length ≥ H(X); entropy is the theoretical floor for lossless coding Shannon, A Mathematical Theory of Communication, 1948