main shows compression ratios again

README also updated to show compression ratios.
This commit is contained in:
Jack Wines 2024-04-15 01:54:33 -07:00
parent 3d1deaacc1
commit 37e28f8c0e
No known key found for this signature in database
GPG key ID: 25B20640600571E6
2 changed files with 8 additions and 5 deletions

View file

@ -1,5 +1,7 @@
Compresses files using [Huffman coding](https://en.wikipedia.org/wiki/Huffman_coding). Please note that decompression isn't fully implemented yet. It is however implemented to the point where we know compression works correctly. Compresses files using [Huffman coding](https://en.wikipedia.org/wiki/Huffman_coding). Please note that decompression isn't fully implemented yet. It is however implemented to the point where we know compression works correctly.
On [The Great Gatsby in plain text](https://www.gutenberg.org/cache/epub/64317/pg64317.txt) on project Gutenberg, it achieves a 0.526 compression ratio when using a word size of two bytes. On an arbitrary RAW image, it peaks at .622 with a 32 bit word size and .645 with a 16 bit one.
To run with [Nix](nixos.org): To run with [Nix](nixos.org):
``` sh ``` sh
nix run ".#" --experimental-features "nix-command flakes" -- myFile nix run ".#" --experimental-features "nix-command flakes" -- myFile

View file

@ -140,9 +140,10 @@ main :: IO ()
main = do main = do
[filePath] <- SE.getArgs [filePath] <- SE.getArgs
f <- BS.readFile filePath f <- BS.readFile filePath
-- TIO.putStrLn "compression ratios:" TIO.putStrLn "does decompress . compress == id ?"
print . ("Word64",) . testCompression (D.Proxy :: D.Proxy Word16) $ f print . ("Word64",) . testCompression (D.Proxy :: D.Proxy Word16) $ f
-- print . ("Word64",) . compressionRatioFor (D.Proxy :: D.Proxy Word64) $ f TIO.putStrLn "compression ratios:"
-- print . ("Word32",) . compressionRatioFor (D.Proxy :: D.Proxy Word32) $ f print . ("Word64",) . compressionRatioFor (D.Proxy :: D.Proxy Word64) $ f
-- print . ("Word16",) . compressionRatioFor (D.Proxy :: D.Proxy Word16) $ f print . ("Word32",) . compressionRatioFor (D.Proxy :: D.Proxy Word32) $ f
-- print . ("Word8",) . compressionRatioFor (D.Proxy :: D.Proxy Word8) $ f print . ("Word16",) . compressionRatioFor (D.Proxy :: D.Proxy Word16) $ f
print . ("Word8",) . compressionRatioFor (D.Proxy :: D.Proxy Word8) $ f