mitogen/preamble_size.py

30 lines
789 B
Python
Raw Normal View History

2016-08-26 18:42:40 +00:00
"""
Print the size of a typical SSH command line and the bootstrap code sent to new
contexts.
"""
import inspect
import zlib
import econtext.master
import econtext.ssh
2016-11-01 11:38:24 +00:00
import econtext.sudo
import econtext.proxy
2016-08-26 18:42:40 +00:00
context = econtext.master.Context(None, name='default', hostname='default')
stream = econtext.ssh.Stream(context)
print 'SSH command size: %s' % (len(' '.join(stream.get_boot_command())),)
print 'Preamble size: %s (%.2fKiB)' % (
len(stream.get_preamble()),
len(stream.get_preamble()) / 1024.0,
)
2016-11-01 11:38:24 +00:00
for mod in (
econtext.master,
econtext.ssh,
econtext.sudo,
econtext.proxy
):
sz = len(zlib.compress(econtext.master.minimize_source(inspect.getsource(mod))))
print '%s size: %s (%.2fKiB)' % (mod.__name__, sz, sz / 1024.0)