Exemplo n.º 1
0
    def generate_html(self):
        """
        Generate HTML.
        """
        html = HTMLDocument("Results")

        # Output comparison of each phase to a different table.
        # for store in self.run_data.keys():
        #     per_phase = self.run_data[store]
        #     html.add_header(1, store)

        for phase in self.run_data.keys():
            per_phase = self.run_data[phase]

            # Make the table header columns and the table.
            columns = [
                "Asset Metadata Amount",
            ]
            ms_keys = sorted(self.all_modulestores)
            for k in ms_keys:
                columns.append("Time Taken (ms) ({})".format(k))
            phase_table = HTMLTable(columns)
            if phase != 'get_asset_list':
                for amount in sorted(per_phase.keys()):
                    per_amount = per_phase[amount]
                    row = [
                        amount,
                    ]
                    for modulestore in ms_keys:
                        time_taken = per_amount[modulestore]
                        row.append("{}".format(time_taken))
                    phase_table.add_row(row)
                html.add_header(2, phase)
                html.add_to_body(phase_table.table)
            else:
                # get_asset_list phase includes the sort as well.
                html.add_header(2, phase)
                for sort in per_phase.keys():
                    sort_table = HTMLTable(columns)
                    per_sort = per_phase[sort]
                    for amount in sorted(per_sort.keys()):
                        per_amount = per_sort[amount]
                        row = [
                            amount,
                        ]
                        for modulestore in ms_keys:
                            # Each sort has two different ranges retrieved.
                            time_taken = per_amount[modulestore] / 2.0
                            row.append("{}".format(time_taken))
                        sort_table.add_row(row)
                    html.add_header(3, sort)
                    html.add_to_body(sort_table.table)

        return html
Exemplo n.º 2
0
    def generate_html(self):
        """
        Generate HTML.
        """
        html = HTMLDocument("Results")

        # Output comparison of each phase to a different table.
        for phase in self.run_data.keys():
            if phase in ('fake_assets',):
                continue
            per_phase = self.run_data[phase]
            html.add_header(1, phase)

            title_map = {
                'duration': 'Total Duration (ms)',
                'ratio': 'Total Duration Per Number of Assets (ms/asset)',
                'variable_cost': 'Asset Export Duration Per Number of Assets (ms/asset)'
            }
            for table_type in ('duration', 'ratio', 'variable_cost'):
                if phase == 'all' and table_type in ('ratio', 'variable_cost'):
                    continue
                # Make the table header columns and the table.
                columns = ["Asset Metadata Amount", ]
                ms_keys = sorted(self.all_modulestore_combos)
                for k in ms_keys:
                    columns.append("{} ({})".format(k, table_type))
                phase_table = HTMLTable(columns)

                # Make a row for each amount of asset metadata.
                for amount in sorted(per_phase.keys()):
                    per_amount = per_phase[amount]
                    num_assets = int(amount)
                    row = [amount, ]
                    for modulestore in ms_keys:
                        if table_type == 'duration':
                            value = per_amount[modulestore]
                        elif table_type == 'ratio':
                            if num_assets != 0:
                                value = per_amount[modulestore] / float(amount)
                            else:
                                value = 0
                        elif table_type == 'variable_cost':
                            if num_assets == 0:
                                value = 0
                            else:
                                value = (per_amount[modulestore] - per_phase['0'][modulestore]) / float(amount)
                        row.append("{}".format(value))
                    phase_table.add_row(row)

                # Add the table title and the table.
                html.add_header(2, title_map[table_type])
                html.add_to_body(phase_table.table)

        return html
Exemplo n.º 3
0
    def generate_html(self):
        """
        Generate HTML.
        """
        html = HTMLDocument("Results")

        # Output comparison of each phase to a different table.
        for phase in self.run_data.keys():  # lint-amnesty, pylint: disable=consider-iterating-dictionary, too-many-nested-blocks
            if phase in ('fake_assets',):
                continue
            per_phase = self.run_data[phase]
            html.add_header(1, phase)

            title_map = {
                'duration': 'Total Duration (ms)',
                'ratio': 'Total Duration Per Number of Assets (ms/asset)',
                'variable_cost': 'Asset Export Duration Per Number of Assets (ms/asset)'
            }
            for table_type in ('duration', 'ratio', 'variable_cost'):
                if phase == 'all' and table_type in ('ratio', 'variable_cost'):
                    continue
                # Make the table header columns and the table.
                columns = ["Asset Metadata Amount", ]
                ms_keys = sorted(self.all_modulestore_combos)
                for k in ms_keys:
                    columns.append("{} ({})".format(k, table_type))
                phase_table = HTMLTable(columns)

                # Make a row for each amount of asset metadata.
                for amount in sorted(per_phase.keys()):
                    per_amount = per_phase[amount]
                    num_assets = int(amount)
                    row = [amount, ]
                    for modulestore in ms_keys:
                        if table_type == 'duration':
                            value = per_amount[modulestore]
                        elif table_type == 'ratio':
                            if num_assets != 0:
                                value = per_amount[modulestore] / float(amount)
                            else:
                                value = 0
                        elif table_type == 'variable_cost':
                            if num_assets == 0:
                                value = 0
                            else:
                                value = (per_amount[modulestore] - per_phase['0'][modulestore]) / float(amount)
                        row.append("{}".format(value))
                    phase_table.add_row(row)

                # Add the table title and the table.
                html.add_header(2, title_map[table_type])
                html.add_to_body(phase_table.table)

        return html
Exemplo n.º 4
0
    def generate_html(self):
        """
        Generate HTML.
        """
        html = HTMLDocument("Results")

        # Output comparison of each phase to a different table.
        # for store in self.run_data.keys():
        #     per_phase = self.run_data[store]
        #     html.add_header(1, store)

        for phase in self.run_data.keys():
            per_phase = self.run_data[phase]

            # Make the table header columns and the table.
            columns = ["Asset Metadata Amount", ]
            ms_keys = sorted(self.all_modulestores)
            for k in ms_keys:
                columns.append("Time Taken (ms) ({})".format(k))
            phase_table = HTMLTable(columns)
            if phase != 'get_asset_list':
                for amount in sorted(per_phase.keys()):
                    per_amount = per_phase[amount]
                    row = [amount, ]
                    for modulestore in ms_keys:
                        time_taken = per_amount[modulestore]
                        row.append("{}".format(time_taken))
                    phase_table.add_row(row)
                html.add_header(2, phase)
                html.add_to_body(phase_table.table)
            else:
                # get_asset_list phase includes the sort as well.
                html.add_header(2, phase)
                for sort in per_phase.keys():
                    sort_table = HTMLTable(columns)
                    per_sort = per_phase[sort]
                    for amount in sorted(per_sort.keys()):
                        per_amount = per_sort[amount]
                        row = [amount, ]
                        for modulestore in ms_keys:
                            # Each sort has two different ranges retrieved.
                            time_taken = per_amount[modulestore] / 2.0
                            row.append("{}".format(time_taken))
                        sort_table.add_row(row)
                    html.add_header(3, sort)
                    html.add_to_body(sort_table.table)

        return html