示例#1
0
def select_benchmarks(names):
    '''
    return <names> but with '<suite>.all' replaced with all benchmarks from <suite>
    and 'all' replaced with all benchmarks.
    '''
    if names is None:
        return []

    bm_list = []
    for name in names:
        # add all benchmarks from a suite
        if '.all' in name:
            # strip '.all' from the end of name
            suite = name.rstrip('.all')
            rows = db_utils.find('benchmarks', fields={'suite': suite})
            # add benchmarks matching suite
            bm_list += [b.name for b in rows]

        # add all benchmarks
        elif name == 'all':
            rows = db_utils.find('benchmarks', fields={})
            return [b.name for b in rows]

        # add an individual benchmark by name
        elif bm_list.count(name) == 0:
            bm_list.append(name)
    return bm_list
示例#2
0
def select_benchmarks(names):
    '''
    return <names> but with '<suite>.all' replaced with all benchmarks from <suite>
    and 'all' replaced with all benchmarks.
    '''
    if names is None:
        return []

    bm_list = []
    for name in names:
        # add all benchmarks from a suite
        if '.all' in name:
            # strip '.all' from the end of name
            suite = name.rstrip('.all')
            rows = db_utils.find('benchmarks', fields={'suite': suite})
            # add benchmarks matching suite
            bm_list += [b.name for b in rows]

        # add all benchmarks
        elif name == 'all':
            rows = db_utils.find('benchmarks', fields={})
            return [b.name for b in rows]

        # add an individual benchmark by name
        elif bm_list.count(name) == 0:
            bm_list.append(name)
    return bm_list
示例#3
0
def get_stat_choices():
    ''' 
    return a (nested) dict of stats: {display_name: submit_name}
    '''
    # use the last core and processor stats
    core_stats    = db_utils.find('stats', fields={'type': 'core'})[0].stats
    proc_stats    = db_utils.find('stats', fields={'type': 'processor'})[0].stats
    process_stats = db_utils.find('stats', fields={'type': 'process'})[0].stats
    stat_choices  = {'core': core_stats, 'processor': proc_stats, 'process': process_stats}

    # replace the stat value with the submit_name (hierarchical name joined by '.')
    def replace_value(d, name=None):
        for k,v in d.items():
            if name is None:
                new_name = k
            else:
                new_name = name + '.' + k

            if isinstance(v, dict):
                d[k] = replace_value(v, new_name)
            else:
                d[k] = new_name
        return d

    # order each dict/sub-dict
    def order(d):
        for k,v in d.items():
            if isinstance(v, dict):
                d[k] = order(v)
        return ordereddict.OrderedDict(sorted(d.items()))

    return order(replace_value(stat_choices))
示例#4
0
def get_column(table, knob_name):
    # get all knobs
    knobs = db_utils.find('knobs', fields={'type': table})

    # build the new column
    new_col = [knob_name]
    new_col += map(lambda k: k.knobs.get(knob_name, ''), knobs)

    return new_col
示例#5
0
def get_column(table, knob_name):
    # get all knobs
    knobs = db_utils.find('knobs', fields={'type': table})

    # build the new column
    new_col = [knob_name]
    new_col += map(lambda k: k.knobs.get(knob_name, ''), knobs)

    return new_col
示例#6
0
def get_processor_choices():
    ''' 
    returns a sorted tuple list of processor types ((<knob0.id>, <knob0.name>), (<knob1.id>, <knob1.name>), ...)
    '''
    # get all knobs
    rows = db_utils.find('knobs', fields={'type': 'processor'})

    # make them into tuples of (pid, display_name)
    processors = tuple([(r.name, r.name) for r in sorted(rows, key=lambda row: row.name)])

    logging.debug(processors)
    return processors
示例#7
0
def get_processor_choices():
    ''' 
    returns a sorted tuple list of processor types ((<knob0.id>, <knob0.name>), (<knob1.id>, <knob1.name>), ...)
    '''
    # get all knobs
    rows = db_utils.find('knobs', fields={'type': 'processor'})

    # make them into tuples of (pid, display_name)
    processors = tuple([(r.name, r.name)
                        for r in sorted(rows, key=lambda row: row.name)])

    logging.debug(processors)
    return processors
示例#8
0
def get_stat_choices():
    ''' 
    return a (nested) dict of stats: {display_name: submit_name}
    '''
    # use the last core and processor stats
    core_stats = db_utils.find('stats', fields={'type': 'core'})[0].stats
    proc_stats = db_utils.find('stats', fields={'type': 'processor'})[0].stats
    process_stats = db_utils.find('stats', fields={'type': 'process'})[0].stats
    stat_choices = {
        'core': core_stats,
        'processor': proc_stats,
        'process': process_stats
    }

    # replace the stat value with the submit_name (hierarchical name joined by '.')
    def replace_value(d, name=None):
        for k, v in d.items():
            if name is None:
                new_name = k
            else:
                new_name = name + '.' + k

            if isinstance(v, dict):
                d[k] = replace_value(v, new_name)
            else:
                d[k] = new_name
        return d

    # order each dict/sub-dict
    def order(d):
        for k, v in d.items():
            if isinstance(v, dict):
                d[k] = order(v)
        return ordereddict.OrderedDict(sorted(d.items()))

    return order(replace_value(stat_choices))
示例#9
0
def initialize():
    # clear the tables
    tables['processor'] = {}
    tables['core'] = {}

    # get the processors from the db
    processors = db_utils.find('knobs', fields={'type': 'processor'})

    # header row
    tables['processor'] = [['name']]

    # add one row for each processor
    for p in processors:
        tables['processor'].append([p.name])

    # get the cores from the db
    cores = db_utils.find('knobs', fields={'type': 'core'})

    # header row
    tables['core'] = [['name']]

    # add one row for each core
    for c in cores:
        tables['core'].append([c.name])
示例#10
0
def initialize():
    # clear the tables
    tables['processor'] = {}
    tables['core'] = {}

    # get the processors from the db
    processors = db_utils.find('knobs', fields={'type': 'processor'})

    # header row
    tables['processor'] = [['name']]

    # add one row for each processor
    for p in processors:
        tables['processor'].append([p.name])

    # get the cores from the db
    cores = db_utils.find('knobs', fields={'type': 'core'})

    # header row
    tables['core'] = [['name']]

    # add one row for each core
    for c in cores:
        tables['core'].append([c.name])
示例#11
0
def get_benchmark_choices():
    '''
    returns a nested tuple list of suites and benchmarks.
    ((<suite_name0>, (<bm0.name>, <bm0.name>), (<bm1.name>, <bm1.name>), ...), (<suite_name1>, ...))
    '''
    suites = db_utils.distinct('benchmarks', field='suite')
    benchmarks = (('all', 'all'), )
    for suite in suites:
        bms = db_utils.find('benchmarks', fields={'suite': suite})
        # first tuple of each suite is for selecting the whole suite
        bm_tuple = ((suite + '.all', 'all'), )
        # for each benchmar, append (b.name, b.name)
        bm_tuple += tuple([(b.name, b.name) for b in bms])
        # add the suite to the master list of benchmarks
        benchmarks += ((suite, (bm_tuple)), )

    # logging.debug(benchmarks)
    return benchmarks
示例#12
0
def get_benchmark_choices():
    '''
    returns a nested tuple list of suites and benchmarks.
    ((<suite_name0>, (<bm0.name>, <bm0.name>), (<bm1.name>, <bm1.name>), ...), (<suite_name1>, ...))
    '''
    suites = db_utils.distinct('benchmarks', field='suite')
    benchmarks = (('all', 'all'),)
    for suite in suites:
        bms = db_utils.find('benchmarks', fields={'suite': suite})
        # first tuple of each suite is for selecting the whole suite
        bm_tuple = ((suite + '.all', 'all'),)
        # for each benchmar, append (b.name, b.name)
        bm_tuple += tuple([(b.name, b.name) for b in bms])
        # add the suite to the master list of benchmarks
        benchmarks += ((suite, (bm_tuple)),)

    # logging.debug(benchmarks)
    return benchmarks