Skip to content

Replace incorrect compression ratio formula with data savings formula.

I discovered this script in one of Fedora Magazine's articles.

Issue: I found that the values printed in the Compression Ratio column were hard to understand and mislabeled.

Explanation: The current formula, 100 * Compressed over Uncompressed, finds the size of the compressed file compared to the original file. This does not actually return the compression ratio which would be Uncompressed over Compressed, which is also not easy to understand as most people understand percentages rather than pure ratios.

As such, I believe the simplest method would be to show the percentage of how much the file is reduced. This allows for the easiest digestion of how efficient each level is for time spent versus percentage of original size reduced.

Solution:

Current:

Screenshot_from_2023-03-07_04-58-29

Merge:

Screenshot of my changes

Taking a look at wikipedia, changes were to simply group the variables and subtract them from 1 before multiplying by 100. As seen above there are also some format changes:

  1. Changed the middle column text to better represent the new formula.
  2. Increased the rounding scale before printf trimmed decimal points to be more precise, since there could be many repeated values and bc is calculating it anyway.
  3. I believed the spaces between the unit notations like " s" and " %" were redundant and harder to read so I trimmed the white space, and the changed the column spacing accordingly

Merge request reports

Loading