示例#1
0
def main():
    cmdlineparser = argparse.ArgumentParser(description = 'BonnieSample Parser', prog = 'BonnieSample')
    cmdlineparser.add_argument('db', nargs='+')

    ns = cmdlineparser.parse_args(sys.argv[1:])
    if len(ns.db) != 2:
        print('Usages')

    db0 = get_samples_in_dir(ns.db[0])
    db1 = get_samples_in_dir(ns.db[1])

    for t in db0:
        t.parse()

    for t in db1:
        t.parse()

    #print(type(NamedTree.operator.average))

    #average0 = NamedTree.operator.average(*db0)
    #average0.set_name(os.path.basename(ns.db[0]))
    group0 = NamedTreeGroup(*db0)
    average0 = group0.average()
    average0.name = os.path.basename(ns.db[0])
    #average1 = NamedTree.operator.average(*db1)
    #average1.set_name(os.path.basename(ns.db[1]))
    group1 = NamedTreeGroup(*db1)
    average1 = group1.average()
    average1.name = os.path.basename(ns.db[1])

    diff_ratio = NamedTree.Operator.diff_ratio(average0, average1)


    #union = NamedTree.operator.union(average0, average1, diff_ratio)
    #NamedTree.painter.single(union)

    ngroup = BonnieSampleGroup(average0, average1, diff_ratio)
    #ngroup.painter = NamedTreePainter(info)

    ngroup.pnt_result()
示例#2
0
def main():
    cmdlineparser = argparse.ArgumentParser(description = 'Sample Parser', prog = 'Sample')
    cmdlineparser.add_argument('db', nargs='+')

    #TODO a universal command line

    ns = cmdlineparser.parse_args(sys.argv[1:])
    if len(ns.db) < 0:
        print('Usages')
        exit()

    average_list = []

    for db in ns.db:
        DB = ctcs2.LogDB(db)
        db = DB.samples('qa_iozone_4-32G', 'qa_iozone_4-32G', IOzoneSample)
        if len(db) == 0:
            log.warning('[IOzone] There is no log files from %s' % ns.db[0])
            continue
        for t in db:
            t.parse_default()
        group = NamedTreeGroup(*db)
        average = group.average()
        average.name = DB.name
        average_list.append(average)

    def note_over_10_percent (v_list):
        if v_list[0] < -0.1:
            return '***'
        else:
            return '   '

    a_iter = iter(average_list)
    r_base = next(a_iter)
    r_list = list()
    r_list.append(r_base)
    spec_end = {r_base.name:'.0f'}
    field_suffix = {}
    while True:
        try:
            r_this = next(a_iter)
        except StopIteration:
            break
        else:
            r_diff_ratio = NamedTree.Operator.diff_ratio(r_base, r_this)
            r_diff_ratio_percent = NamedTree.Operator.scale_multiply(r_diff_ratio, scale = 100)
            r_diff_ratio_percent.name = 'Fluctuation'
            r_diff_ratio_note = NamedTree.Operator.user_defined(r_diff_ratio, cb_func = note_over_10_percent)
            r_diff_ratio_note.name = 'ratio_note'
            
            spec_end[r_this.name] = '.0f'
            spec_end[r_diff_ratio_percent.name] = '.2f'
            spec_end[r_diff_ratio_note.name] = 's'
            field_suffix[r_diff_ratio_percent.name] = " %"
            r_list.append(r_this)
            r_list.append(r_diff_ratio_percent)
            r_list.append(r_diff_ratio_note)

    ngroup = NamedTreeGroup(*r_list)
    ngroup.leaf_render.set_field_format_spec_end(**spec_end)
    ngroup.leaf_render.set_field_suffix(**field_suffix)
    ngroup.leaf_print()