![]() So which should you use? It’s going to come down to using the right tool for the job and the particular data set that you are working with. ![]() However decompressing with bzip2 takes much longer than xz or gzip, xz is a good middle ground here while gzip is again the fastest. Therefore using xz with a compression level of 1 instead of gzip for a better compression ratio in a faster time.īased on these results, bzip2 is a good middle ground for compression, gzip is only a little faster while xz may not really worth it at its higher default compression ratio of 6 as it takes much longer to complete for little extra gain. Interestingly the lowest xz compression level of 1 results in a higher compression ratio than gzip with a compression level of 9 and even completes faster. Xz takes a lot more time with its default compression level of 6 while bzip2 only takes a little longer than gzip at compression level 9 and compresses a fair amount better, while the difference between bzip2 and xz is less than the difference between bzip2 and gzip making bzip2 a good trade off for compression. In order to achieve better compression however xz usually takes the longest to complete, followed by bzip2 and then gzip. In general xz achieves the best compression level, followed by bzip2 and then gzip. ![]() Bzip2 on the other hand is best used with the default compression level of 9 as is also recommended in the manual page, the results here confirm this, the compression ratio increases but the time taken is almost the same and differs by less than a second between levels 1 to 9. For gzip and xz -6 as a default compression method provides a good level of compression yet does not take too long to complete, it’s a fair trade off point as higher compression levels take longer to process. The reason for this is pretty clear based on the results. Gzip vs Bzip2 vs XZ Decompression Speed Performance Differences and Comparisonīy default when the compression level is not specified, gzip uses -6, bzip2 uses -9 and xz uses -6. The table below indicates the size in bytes of the linux-3.18.19.tar file after compression, the first column numbered 1.9 shows the compression level passed in to the compression tool.įirst we’ll start with the compression time, this graph shows how long it took for the compression to complete at each compression level 1 through to 9. The raw data that the below graphs have been created from has been provided in tables below and can also be accessed in this spreadsheet. The versions pf these tools were gzip 1.5, bzip2 1.0.6, and xz (XZ Utils) 5.1.2alpha. To decompress, the same command was used with the -d flag. To save and reduce CPU processing time a lower compression level can be used which will result in a lower compression ratio, using more disk space.Įach time the compression or decompression command was run, the ‘time’ command was placed in front so that we could accurately measure how long the command took to execute.īelow are the commands that were run for compression level 1: time bzip2 -1v linux-3.18.19.tarĪll commands were run with the time command, verbosity and the compression level of -1 which was stepped through incrementally up to -9. To get a higher compression ratio and save a greater amount of disk space, more CPU processing time will be required. ![]() There is an important trade off here between the compression levels between CPU processing time and the compression ratio. Compression level 9 on the other hand is the best possible compression level, however it will take the longest amount of time to complete. A compression level of 1 indicates that the compression will be fastest but the compression ratio will not be as high so the file size will be larger. The linux-3.18.19.tar file was compressed and decompressed 9 times each by gzip, bzip2 and xz at each available compression level from 1 to 9. This file was 580,761,600 Bytes in size prior to compression. With XZ it is possible to specify the amount of threads to run which can greatly increase performance, for further information see example 9 here.Īll tests were performed on linux-3.18.19.tar, a copy of the Linux kernel from. The server had 4 CPU cores and 16GB of available memory, during the tests only one CPU core was used as all of these tools run single threaded by default, while testing this CPU core would be fully utilized. The test server was running CentOS with kernel 3.10.0-229.11.1 in use, all updates to date are fully applied. Gzip, Bzip2 and XZ are all popular compression tools used in UNIX based operating systems, but which should you use? Here we are going to benchmark and compare them against each other to get an idea of the trade off between the level of compression and time taken to achieve it.įor further information on how to use gzip, bzip2 or xz see our guides below:
0 Comments
Leave a Reply. |