Skip to content

Instantly share code, notes, and snippets.

@dzderic
Created October 2, 2012 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dzderic/3815451 to your computer and use it in GitHub Desktop.
Save dzderic/3815451 to your computer and use it in GitHub Desktop.
import time
import os
import zipfile
N = 100000
archive = zipfile.ZipFile('something.zip', 'w')
print 'Generating messages'
messages = [os.urandom(1024) for i in range(N)]
print 'Running benchmark'
start = time.time()
for i, msg in enumerate(messages):
archive.writestr('archive-%s' % i, msg)
total = time.time() - start
print "%.2f messages/sec" % (N / total)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment