Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 30 lines (23 sloc) 689 Bytes
#!/usr/bin/env python
# By Gary Bernhardt.
# Dotfiles at:
import sys
import zlib
import bz2
def main():
data = file_data()
size = len(data)
print 'file size', size
gzip_size = len(zlib.compress(data))
print 'gzip size %i (%i%%)' % (gzip_size, percent(gzip_size, size))
bz2_size = len(bz2.compress(data))
print 'bz2 size %i (%i%%)' % (bz2_size, percent(bz2_size, size))
def file_data():
files = map(open, sys.argv[1:])
if not files:
files = [sys.stdin]
return ''.join( for f in files)
def percent(part, whole):
return int(100.0 * part / whole)
if __name__ == '__main__':
Jump to Line
Something went wrong with that request. Please try again.