.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Compress::LZ4 3pm" .TH Compress::LZ4 3pm "2020-11-09" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Compress::LZ4 \- Perl interface to the LZ4 (de)compressor .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Compress::LZ4; \& \& my $compressed = compress($bytes); \& my $decompressed = decompress($compressed); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \f(CW\*(C`Compress::LZ4\*(C'\fR module provides an interface to the \s-1LZ4\s0 (de)compressor. .SH "FUNCTIONS" .IX Header "FUNCTIONS" .SS "compress" .IX Subsection "compress" .Vb 1 \& $compressed = compress($bytes [, $level]) .Ve .PP Compresses the given buffer and returns the resulting bytes. The input buffer can be either a scalar or a scalar reference. The default acceleration level (1) can be changed, with each additional level providing ~3% increase in speed; the compression level will be negatively affected. .SS "compress_hc" .IX Subsection "compress_hc" .Vb 1 \& $compressed = compress_hc($bytes [, $level]) .Ve .PP A higher-compression, but slower, version of \f(CW\*(C`compress\*(C'\fR. The default compression level (9) can be changed if an optional value (0\-16) is given. .SS "decompress" .IX Subsection "decompress" .SS "uncompress" .IX Subsection "uncompress" .Vb 1 \& $bytes = decompress($compressed) .Ve .PP Decompresses the given buffer and returns the resulting bytes. The input buffer can be either a scalar or a scalar reference. .PP On error (in case of corrupted data) undef is returned. .SH "COMPATIBILITY" .IX Header "COMPATIBILITY" This library does not produce output that is compatible with the official frame format. Because \s-1LZ4\s0 did not define a container format until long after it was released, many bindings, including this one, prepend the original data size to the compressed data as a little-endian 4\-byte integer. .PP If you are dealing with raw data from an external source that does not format the data this way, you need to use the following functions: .SS "lz4_compress" .IX Subsection "lz4_compress" .SS "lz4_compress_hc" .IX Subsection "lz4_compress_hc" Same as \f(CW\*(C`compress\*(C'\fR/\f(CW\*(C`compress_hc\*(C'\fR but does not add the length header. .SS "lz4_decompress" .IX Subsection "lz4_decompress" .SS "lz4_uncompress" .IX Subsection "lz4_uncompress" .Vb 1 \& $bytes = decompress($compressed, $original_data_size) .Ve .PP Same as \f(CW\*(C`decompress\*(C'\fR/\f(CW\*(C`uncompress\*(C'\fR but also requires the original data size to be given. .SH "PERFORMANCE" .IX Header "PERFORMANCE" This distribution contains a benchmarking script which compares several modules available on \s-1CPAN.\s0 These are the results on a MacBook 2.6GHz Core i5 (64\-bit) with Perl 5.24.1: .PP .Vb 9 \& Compressible data (10 KiB) \- compression \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& Compress::LZ4::compress 8 670690/s 6550 MiB/s 1.152% \& Compress::LZ4::compress 649176/s 6340 MiB/s 1.152% \& Compress::Snappy::compress 367492/s 3589 MiB/s 5.332% \& Compress::LZF::compress 127765/s 1248 MiB/s 1.865% \& Compress::LZ4::compress_hc 84620/s 826 MiB/s 1.152% \& Compress::Zlib::compress 15514/s 152 MiB/s 1.201% \& Compress::Bzip2::compress 246/s 2 MiB/s 2.070% \& \& Compressible data (10 KiB) \- decompression \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& Compress::LZF::decompress 1262620/s 12330 MiB/s \& Compress::LZ4::decompress 819200/s 8000 MiB/s \& Compress::Snappy::decompress 619934/s 6054 MiB/s \& Compress::Zlib::uncompress 65163/s 636 MiB/s \& Compress::Bzip2::decompress 12679/s 124 MiB/s \& \& Uncompressible data (10 KiB) \- compression \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& Compress::LZ4::compress 8 2102098/s 20528 MiB/s 109.231% \& Compress::LZ4::compress 1854792/s 18113 MiB/s 109.231% \& Compress::Snappy::compress 1619124/s 15812 MiB/s 104.615% \& Compress::LZF::compress 1349269/s 13176 MiB/s 101.538% \& Compress::LZ4::compress_hc 96376/s 941 MiB/s 109.231% \& Compress::Zlib::compress 66370/s 648 MiB/s 112.308% \& Compress::Bzip2::compress 54098/s 528 MiB/s 201.538% \& \& Uncompressible data (10 KiB) \- decompression \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& Compress::LZF::decompress 5004566/s 48873 MiB/s \& Compress::LZ4::decompress 4915199/s 48000 MiB/s \& Compress::Snappy::decompress 4906438/s 47914 MiB/s \& Compress::Zlib::uncompress 355071/s 3467 MiB/s \& Compress::Bzip2::decompress 175812/s 1717 MiB/s .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" .SH "REQUESTS AND BUGS" .IX Header "REQUESTS AND BUGS" Please report any bugs or feature requests to . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. .SH "SUPPORT" .IX Header "SUPPORT" You can find documentation for this module with the perldoc command. .PP .Vb 1 \& perldoc Compress::LZ4 .Ve .PP You can also look for information at: .IP "\(bu" 4 GitHub Source Repository .Sp .IP "\(bu" 4 AnnoCPAN: Annotated \s-1CPAN\s0 documentation .Sp .IP "\(bu" 4 \&\s-1CPAN\s0 Ratings .Sp .IP "\(bu" 4 \&\s-1RT: CPAN\s0's request tracker .Sp .IP "\(bu" 4 Search \s-1CPAN\s0 .Sp .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2012\-2017 gray , all rights reserved. .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "AUTHOR" .IX Header "AUTHOR" gray,