'Generate HTML.'

def generate_html(self):

    html = HTMLDocument('Results')
    for phase in self.run_data.keys():
        per_phase = self.run_data[phase]
        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:
            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:
                        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
