LibDeflate
Pure Lua compressors and decompressors with high compression ratio using DEFLATE/zlib format.
Copyright (C) 2018 Haoqian He
Introduction
LibDeflate is pure Lua compressor and decompressor with high compression ratio, which compresses almost as good as zlib. LibDeflate does not have any dependencies except you need to have a working Lua interpreter.
Supported Lua Versions
LibDeflate supports and is fully tested under Lua 5.1/5.2/5.3, LuaJIT 2.0/2.1, for Linux, MaxOS and Windows. See the badge on the top of this README for the test result.
Documentation
Documentation is hosted on Github.
Limitation
Though many performance optimization has been done in the source code, as a pure lua implementation, its speed is significantly slower than a C compressor. LibDeflate aims to compress small files, and it is suggested to not compress files with the order of several Megabytes. If you need to compress files hundreds of MetaBytes, please use a C compressor, or a Lua compressor with C binding.
Performance
Below is a simple benchmark compared with another pure Lua compressor LibCompress.
The size of The input data is 158492 bytes. The benchmark runs on Lua 5.1.4 interpreter.
NOTE: The compression method used by LibDeflate here is LibDeflate:CompressDeflate (Compress using raw DEFLATE format)
LibDeflate | LibDeflate | LibDeflate | LibCompress | LibCompress | |
---|---|---|---|---|---|
level 1 | level 5 | level 8 | CompressLZW | CompressHuffman | |
Compress(ms) | 65 | 150 | 465 | 66 | 75 |
Decompress(ms) | 32 | 28 | 28 | 21 | 99 |
compress size(Bytes) | 23659 | 17323 | 16106 | 72639 | 99346 |
LibDeflate with compression level 1 compresses as fast as LibCompress, but already produces significantly smaller file than LibCompress. High compression level takes a bit more time to get better compression.
Download And Install
+ The official repository locates on Github. LibDeflate.lua is the only file of LibDeflate. Copy the file to your LUA_PATH to install it.
To download as a World of Warcraft library, goto LibDeflate Curseforge Page
You can also install via Luarocks using the command "luarocks install libdeflate"
To use after installation,
<code>require("LibDeflate")</code>
(case sensitive) in your Lua interpreter, or<code>LibStub:GetLibrary("LibDeflate")</code>
(case sensitive) for World of Warcraft.
Usage
See examples/example.lua
Credits
1. zlib, by Jean-loup Gailly (compression) and Mark Adler (decompression). Licensed under zlib License. 2. puff, by Mark Adler. Licensed under zlib License. 3. LibCompress, by jjsheets and Galmok of European Stormrage (Horde). Licensed under GPLv2. 4. WeakAuras2. Licensed under GPLv2.
License
LibDeflate is licensed under GNU General Public License Version 3 or later.