GithubHelp home page GithubHelp logo

libzling's Introduction

libzling

fast and lightweight compression library and utility.

Introduction

Libzling is an improved lightweight compression utility and library. libzling uses fast order-1 ROLZ (16MB block size and 10MB dictionary size) followed with Huffman encoding, making it twice as fast as gzip on compressing, while still getting better compression ratio and decompression speed.

Simple benchmark with enwik8(100,000,000 bytes)

Tool Compressed Size Encode Decode
zling 3219KB 3.18s 1.02s
gzip 3652KB 8.13s 1.47s

Simple benchmark with fp.log(20,617,071 bytes)

Tool Compressed Size Encode Decode
zling 897KB 0.13s 0.07s
gzip 1449KB 0.41s 0.14s

Build & Install

You can build and install libzling automatically by cmake with the following command: cd ./build cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/path/to/install make make install

Usage

Libling provides simple and lightweight interface. here is a simple program showing the basic usage of libzling. (compiled with g++ -Wall -O3 zling_sample.cpp -o zling_sample -lzling)

#include "libzling.h"

int main() {
    // compress
    {
        FILE* fin = fopen("./1.txt", "rb");
        FILE* fout = fopen("./1.txt.zlng", "wb");

        baidu::zling::FileInputer  inputer(fin);
        baidu::zling::FileOutputer outputer(fout);

        baidu::zling::Encode(&inputer, &outputer);
        fclose(fin);
        fclose(fout);
    }

    // decompress
    {
        FILE* fin = fopen("./1.txt.zlng", "rb");
        FILE* fout = fopen("./2.txt", "wb");

        baidu::zling::FileInputer  inputer(fin);
        baidu::zling::FileOutputer outputer(fout);

        baidu::zling::Decode(&inputer, &outputer);
        fclose(fin);
        fclose(fout);
    }
    return 0;
}

However libzling supports more complicated interface, see ./demo/zling.cpp for details.

libzling's People

Contributors

richox avatar

Watchers

James Cloos avatar wyrover avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.