Example #1
0
def test_profile():
    root = ProfileTree("root")
    trace = [["a", "b", "c"], ["a", "c"]]
    # (path, total, self, children)
    exp = [ ("/root", 2, 0, 2),
            ("/root/a", 2, 0, 2),
            ("/root/a/b", 1, 0, 1),
            ("/root/a/b/c", 1, 1, 0),
            ("/root/a/c", 1, 1, 0) ]
    for ev in trace:
        leaf = root.get_or_create_branch(ev)
        leaf.value += 1
    act = make_path_stats(root.preorder)
    check_list(exp, act)

    items = []
    for e in exp:
       items.append(StatItem(e[0], e[1], e[2], e[3]))
    rms = profile_rms_error(items, root)
    assert(rms < 0.0000001)
Example #2
0
def test_create():
    root = ProfileTree("root")
    ev = ["foo", "bar", "baz"]
    root.get_or_create_branch(ev)
    exp = [("root", 0), ("foo", 1), ("bar", 2), ("baz", 3)]
    check_list(exp, make_key_depth(root.preorder))