You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mitogen/preamble_size.py

34 lines
870 B
Python

7 years ago
"""
Print the size of a typical SSH command line and the bootstrap code sent to new
contexts.
"""
import inspect
import zlib
import mitogen.fakessh
7 years ago
import mitogen.master
import mitogen.parent
7 years ago
import mitogen.ssh
import mitogen.sudo
router = mitogen.master.Router()
context = mitogen.parent.Context(router, 0)
stream = mitogen.ssh.Stream(router, 0, max_message_size=0, hostname='foo')
7 years ago
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,
)
for mod in (
mitogen.master,
mitogen.parent,
7 years ago
mitogen.ssh,
mitogen.sudo,
mitogen.fakessh,
7 years ago
):
sz = len(zlib.compress(mitogen.parent.minimize_source(inspect.getsource(mod))))
7 years ago
print '%s size: %s (%.2fKiB)' % (mod.__name__, sz, sz / 1024.0)