Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # zipping/gzipping binary data vs. base64 encoded data
- # tested on debian squeeze, zip 3.0-3, gzip 1.3.12-9
- for i in 1 10 100 1024 2048 4096; do
- dd if=/dev/urandom of=test_${i}_bin.bin bs=1k count=$i
- php -r "file_put_contents('test_${i}_base64.txt', base64_encode(file_get_contents('test_${i}_bin.bin')));"
- zip test_${i}_bin.zip test_${i}_bin.bin
- zip test_${i}_base64.zip test_${i}_base64.txt
- cat test_${i}_bin.bin | gzip -c9 > test_${i}_bin.gz
- cat test_${i}_base64.txt | gzip -c9 > test_${i}_base64.gz
- ls -alb test_${i}_*
- done
- # formated a bit...
- 1024 test_1_bin.bin
- 1368 test_1_base64.txt
- 1202 test_1_bin.zip
- 1243 test_1_base64.zip
- 1047 test_1_bin.gz
- 1077 test_1_base64.gz
- 10240 test_10_bin.bin
- 13656 test_10_base64.txt
- 10420 test_10_bin.zip
- 10527 test_10_base64.zip
- 10263 test_10_bin.gz
- 10359 test_10_base64.gz
- 102400 test_100_bin.bin
- 136536 test_100_base64.txt
- 102602 test_100_bin.zip
- 103513 test_100_base64.zip
- 102438 test_100_bin.gz
- 103343 test_100_base64.gz
- 1048576 test_1024_bin.bin
- 1398104 test_1024_base64.txt
- 1048754 test_1024_bin.gz
- 1058208 test_1024_base64.zip
- 1048920 test_1024_bin.zip
- 1058036 test_1024_base64.gz
- 2097152 test_2048_bin.bin
- 2796204 test_2048_base64.txt
- 2097656 test_2048_bin.zip
- 2116195 test_2048_base64.zip
- 2097490 test_2048_bin.gz
- 2116023 test_2048_base64.gz
- 4194304 test_4096_bin.bin
- 5592408 test_4096_base64.txt
- 4195128 test_4096_bin.zip
- 4232178 test_4096_base64.zip
- 4194962 test_4096_bin.gz
- 4232006 test_4096_base64.gz
- # base64 encoded data takes 0.8-2% more space than binary when zipped/gzipped
- # note: zipping with "-9" does not make any difference
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement