def run(self):
        self.create_databases()

        for db_alias in connections:
            self.current_db_alias = db_alias
            connection = connections[db_alias]

            for model in sorted(self.models, key=lambda m: m.__name__):
                print('-' * 50)
                print('%s on %s' % (self.models[model], connection.vendor))
                it = self.populate_database(model)
                progress = tqdm(it, total=self.rows_count)
                elapsed_time = 0.0
                while True:
                    try:
                        start = time() - elapsed_time
                        count = next(it)
                        elapsed_time = time() - start
                    except StopIteration:
                        break
                    progress.update(count - progress.n)
                    self.add_data(model, 'Create all objects', count,
                                  elapsed_time, y_label=WRITE_LATENCY)
                    with connection.cursor() as cursor:
                        # This makes sure the table statistics are
                        # up to date and the disk usage is optimised.
                        cursor.execute(
                            'VACUUM ANALYZE "%s";' % model._meta.db_table)
                        # This makes sure the indexes are up to date.
                        cursor.execute(
                            'REINDEX TABLE "%s";' % model._meta.db_table)
                    self.run_tests(model, count)
                # We delete the objects to avoid impacting
                # the following tests and to clear some disk space.
                model.objects.all().delete()

        df = pd.DataFrame(self.data)
        df.to_csv(os.path.join(self.results_path, 'data.csv'), index=False)

        stats_df = df.set_index(['Database', 'Test name', 'Count'])
        stats_df.sort_index(inplace=True)
        group_by = stats_df.groupby(level=[0, 1, 2])
        min_values_series = group_by.min()['Value']
        max_values_series = group_by.max()['Value']
        stats_df['Value'] = ((stats_df['Value'] - min_values_series)
                             / (max_values_series - min_values_series))
        stats_df['Value'] = stats_df['Value'].fillna(1.0)
        stats_df = stats_df.groupby(['Y label', 'Implementation']).mean()
        stats_df['Value'] = ((20 * (1 - stats_df['Value']))
                             .apply(lambda f: '%.1f / 20' % f))
        stats_df.to_html(os.path.join(self.results_path, 'stats.html'),
                         header=False)

        df.set_index('Count', inplace=True)
        for database_name in df['Database'].unique():
            for test_name in df['Test name'].unique():
                sub_df = df[(df['Database'] == database_name)
                            & (df['Test name'] == test_name)]
                y_labels = sub_df['Y label'].unique()
                assert len(y_labels) == 1
                sub_df = sub_df.pivot(columns='Implementation', values='Value')
                self.plot(sub_df, database_name, test_name, y_labels[0])
dataset/ETHPy150Open BertrandBordage/django-tree/benchmark/base.py/Benchmark.run/original