Codebase list logbook / 7e41e78b-d633-4bb2-9787-9589652ceae7/main benchmark / bench_stack_manipulation.py
7e41e78b-d633-4bb2-9787-9589652ceae7/main

Tree @7e41e78b-d633-4bb2-9787-9589652ceae7/main (Download .tar.gz)

bench_stack_manipulation.py @7e41e78b-d633-4bb2-9787-9589652ceae7/mainraw · history · blame

"""Tests basic stack manipulation performance"""
from logbook import Handler, NullHandler, StreamHandler, FileHandler, \
    ERROR, WARNING
from tempfile import NamedTemporaryFile
from cStringIO import StringIO


def run():
    f = NamedTemporaryFile()
    out = StringIO()
    with NullHandler():
        with StreamHandler(out, level=WARNING):
            with FileHandler(f.name, level=ERROR):
                for x in xrange(100):
                    list(Handler.stack_manager.iter_context_objects())