当前位置: 首页>>代码示例>>Python>>正文


Python Table.set_header方法代码示例

本文整理汇总了Python中table.Table.set_header方法的典型用法代码示例。如果您正苦于以下问题:Python Table.set_header方法的具体用法?Python Table.set_header怎么用?Python Table.set_header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在table.Table的用法示例。


在下文中一共展示了Table.set_header方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generate_time_table

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import set_header [as 别名]
    def generate_time_table(self):

        table = Table()

        # prepare header
        header = ["procedure"]
        for size in self.data.sizes:
            header.append('%d B' % size)

        table.set_header(header)

        # get data
        for procedure in self.data.procedures:
            data = self.data.data_for_procedure(procedure)
            row = [procedure]

            for item in data:
                fmt = TIME_PATTERN % item.time
                if item.time == self.data.get_shortest_time(item.size):
                    row.append('**%s**' % fmt)
                else:
                    row.append(fmt)

            table.add_row(row)

        return table
开发者ID:dryman,项目名称:sse-popcount,代码行数:28,代码来源:report.py

示例2: generate_speedup_table

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import set_header [as 别名]
    def generate_speedup_table(self):

        table = Table()

        # prepare header
        header = ["procedure"]
        for size in self.data.sizes:
            header.append('%d B' % size)

        table.set_header(header)

        reference_time = {}
        for size in self.data.sizes:
            time = self.data.get(self.data.procedures[0], size)
            reference_time[size] = time

        # get data
        for proc in self.data.procedures:
            measurments = self.data.data_for_procedure(proc)

            row = [proc]
            for item in measurments:
                speedup = reference_time[item.size] / item.time
                row.append('%0.2f' % speedup)

            table.add_row(row)

        return table
开发者ID:dryman,项目名称:sse-popcount,代码行数:30,代码来源:report.py

示例3: main

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import set_header [as 别名]
def main():
    
    table = Table()
    reg   = FunctionRegistry()

    table.set_header(["procedure", "description"])
    for proc, dsc in reg.functions.iteritems():
        table.add_row([proc, dsc])

    print table
开发者ID:WojciechMula,项目名称:sse-popcount,代码行数:12,代码来源:readme_listproc.py

示例4: generate_procedures_descriptions

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import set_header [as 别名]
    def generate_procedures_descriptions(self):

        definitions = self.__parse_cpp()

        table = Table()
        header = ["procedure", "description"]
        table.set_header(header)

        for proc, desc in definitions.iteritems():
            if proc in self.data.procedures:
                table.add_row([proc, desc])

        return table
开发者ID:Eppie,项目名称:sse-popcount,代码行数:15,代码来源:report.py

示例5: generate_procedures_descriptions

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import set_header [as 别名]
    def generate_procedures_descriptions(self):
        
        reg = FunctionRegistry()

        table = Table()
        header = ["procedure", "description"]
        table.set_header(header)

        for proc, desc in reg.functions.iteritems():
            if proc in self.data.procedures:
                table.add_row([proc, desc])

        return table
开发者ID:WojciechMula,项目名称:sse-popcount,代码行数:15,代码来源:report.py

示例6: generate_time_table_for_size

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import set_header [as 别名]
    def generate_time_table_for_size(self, size):

        table = Table()
        table.set_header(["procedure", "time [s]", "relative time"])

        chars = 50

        data = self.data.data_for_size(size)
        max_time = max(item.time for item in data)

        for item in data:
            time = TIME_PATTERN % item.time
            bar  = unicode_bar(item.time/max_time, chars)
            table.add_row([item.procedure, time, bar])

        return table
开发者ID:dryman,项目名称:sse-popcount,代码行数:18,代码来源:report.py

示例7: main

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import set_header [as 别名]
def main():

    with open(sys.argv[1], 'rt') as f:
        available_procedures, data = load(f)
   
    procedures = ["std", "SSE", "AVX2", "binsearch"]

    header = ["size A", "size B", "size ratio"]
    for proc in procedures:
        if proc in available_procedures:
            header.append("%s [us]" % proc)

    table = Table()
    table.set_header(header)

    for key, values in data.iteritems():
        small_size, large_size = key

        row = [
            '%d' % small_size,
            '%d' % large_size,
            '%0.2f' % (large_size/float(small_size)),
        ]

        for proc in procedures:
            if proc in available_procedures:
                row.append('%d' % values[proc])

        table.add_row(row)

        def speedup(base, new):
            try:
                coef = base/float(new)
            except ZeroDivisionError:
                coef = float(base)

            return 'x %0.2f' % coef

        row = ["", "", "", ""]
        for proc in procedures:
            if proc != 'std' and proc in available_procedures:
                row.append(speedup(values['std'], values[proc]))

        table.add_row(row)

    print table
开发者ID:WojciechMula,项目名称:toys,代码行数:48,代码来源:report.py

示例8: main

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import set_header [as 别名]
def main(measurements_path):
    
    table = Table();
    table.set_header(["procedure", "time [us]", "speed-up"])
    
    with open(measurements_path, 'rt') as f:
        for line in f:
            F = map(int, (s.strip() for s in line.split(',')))
            size       = F[0]
            iterations = F[1]
            measurements = F[2:]

            table.add_row([('element count %d' % (size,), 3)])

            reference = float(measurements[0])
            for i, time in enumerate(measurements):
                row = []
                row.append(procedure_name[i])
                row.append('%d' % time)
                row.append('%0.2f' % (reference/time))
                table.add_row(row)

    print table
开发者ID:WojciechMula,项目名称:toys,代码行数:25,代码来源:performance_report.py

示例9: print_report

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import set_header [as 别名]
def print_report(path):

    table1 = Table()
    table2 = Table()

    header_common = [
        "case",
        "size [bits]",
        "cardinality [bits]",
        "fill factor",
    ]

    table1.set_header(header_common + [
        "naive [us]",
        "better [us]",
        "block-3 [us]",
        "block-4 [us]",
    ])

    table2.set_header(header_common + [
        "naive [x]",
        "better [x]",
        "block-3 [x]",
        "block-4 [x]",
    ])

    with open(path, 'rt') as f:
        prev_name = None
        for line in f:
            F = line.split(',')
            assert(len(F) == 7)

            if F[0] == prev_name:
                name = ""
            else:
                name = F[0]
                prev_name = name

            size = int(F[1])
            cardinality = int(F[2])
            fill_factor = float(cardinality)/size

            naive_time  = int(F[3])
            better_time = int(F[4])
            block3_time = int(F[5])
            block4_time = int(F[6])
         
            row_common = [
                name,
                '%d' % size,
                '%d' % cardinality,
                '%0.2f' % fill_factor,
            ]

            table1.add_row(row_common + [
                format(naive_time, ",d"),
                format(better_time, ",d"),
                format(block3_time, ",d"),
                format(block4_time, ",d"),
            ])

            table2.add_row(row_common + [
                "%0.2f" % (float(naive_time)/naive_time),
                "%0.2f" % (float(naive_time)/better_time),
                "%0.2f" % (float(naive_time)/block3_time),
                "%0.2f" % (float(naive_time)/block4_time),
            ])

    print table1
    print
    print table2
开发者ID:WojciechMula,项目名称:toys,代码行数:73,代码来源:print_table.py


注:本文中的table.Table.set_header方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。