Skip to content

Instantly share code, notes, and snippets.

@janaz
Last active June 28, 2018 07:28
Show Gist options
  • Save janaz/539a45b840bc1432b9d051d8faca7020 to your computer and use it in GitHub Desktop.
Save janaz/539a45b840bc1432b9d051d8faca7020 to your computer and use it in GitHub Desktop.
Lambda function - compression comparison

Environment

$ ls -1 .
node_modules
package.json
src
yarn.lock

$ du -sm .
35400	.

Results

Format Size % of p7zip size
zip 3,206,939 103.80
zip (p7zip) 3,089,435 100
tar.gz 2,012,472 65.14
tar.bz2 1,444,009 46.74
tar.xz 1,032,892 33.43

ZIP

Setting best compression using -9 flag

$ zip -9 -r ../lambda.zip .

$ ls -l ../lambda.zip
3206939 Jun 28 17:23 ../lambda.zip

P7ZIP (Compatible with ZIP)

Compressing with p7zip generating a compatible zip file using the best possible compression ratio

$ 7za a -mm=Deflate -mfb=258 -mpass=15 -r ../lambda-p7.zip .

$ ls -l ../lambda-p7.zip
3089435 Jun 28 17:25 ../lambda-p7.zip

Tar/Gzip

Setting best compression using -9 flag

$ tar cf - . | gzip -9 - > ../lambda.tar.gz

$ ls -l ../lambda.tar.gz
2012472 Jun 28 17:14 ../lambda.tar.gz

Tar/Bzip2

Setting best compression using -9 flag

$ tar cf - . | bzip2 -9 - > ../lambda.tar.bz2

$ ls -l ../lambda.tar.bz2
1444009 Jun 28 17:16 ../lambda.tar.bz2

Tar/Xz

Setting best compression using -9 flag

$ tar cf - . | xz -z -9 - > ../lambda.tar.xz

$ ls -l ../lambda.tar.xz
1032892 Jun 28 17:18 ../lambda.tar.xz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment