示例#1
0
def test_format_report_empty():
    b = BenchmarkTimer()
    rows = b.get_report()
    output = format_report(rows)

    lines = output.split("\n")
    assert len(lines) == 2  # headings, ---
示例#2
0
def test_run_multiple():
    b = BenchmarkTimer()
    b.start("This is a test")
    b.end()
    b.start("This is another test")
    b.end()

    rows = b.get_report()
    assert len(rows) == 2
示例#3
0
def test_report_fields():
    b = BenchmarkTimer()
    b.start("This is a test")
    b.end()
    b.start("This is another test")
    b.end()

    rows = b.get_report()
    first_row = rows[0]

    for k in "message amount min max avg".split(" "):
        yield check_report_field, first_row, k
示例#4
0
def test_format_report_multiple():
    b = BenchmarkTimer()

    b.start("This is a test")
    b.end()
    b.start("This is another test")
    b.end()

    rows = b.get_report()
    output = format_report(rows)

    lines = output.split("\n")
    assert len(lines) == 4  # headings, ---, message
示例#5
0
def test_blank_report():
    b = BenchmarkTimer()
    rows = b.get_report()
    assert len(rows) == 0
示例#6
0
def test_start_twice():
    b = BenchmarkTimer()
    b.start("This is a test")
    b.start("This is a test")
示例#7
0
def test_end_before_start():
    b = BenchmarkTimer()
    b.end()
示例#8
0
    # make a widget and show it so that we have a widget to use to allocate
    # colours and pass it to make_pango_layout (which uses it to make a new
    # layout)
    widget = gtk.Window()
    widget.show()

    view.colours = get_colours(widget,
                               view.document.tokenizer.lexer,
                               colourscheme)

    offset = (0, 0)
    size = view.textbox_dimensions
    tab_size = 8

    b = BenchmarkTimer()

    for x in xrange(1000):
        b.start("Warmup (must relex)")
        view.document.invalidate((0, 0))
        view.document.update_tokens(offset, size)
        layout = make_pango_layout(view, widget)
        b.end()

    for x in xrange(1000):
        b.start("Normal (no lexing)")
        view.document.update_tokens(offset, size)
        layout = make_pango_layout(view, widget)
        b.end()

    print