def METHOD_NAME(stats, gpu, params, output):
    median_table = []
    total_table = []
    index = ["catboost", "xgboost", "lightgbm"]
    for algorithm_name in index:
        median_row = []
        total_row = []
        if gpu:
            algorithm_name += "-GPU"
        else:
            algorithm_name += "-CPU"
        for experiment_name in stats:
            experiment_stats = stats[experiment_name]
            if algorithm_name not in experiment_stats:
                continue
            if params not in experiment_stats[algorithm_name]:
                median_row.append(0.)
                total_row.append(0.)
                continue
            cur_stat = experiment_stats[algorithm_name][params]
            median_row.append(get_median_str(cur_stat))
            total_row.append(np.round(cur_stat["TotalTime"], 3))
        median_table.append(median_row)
        total_table.append(total_row)
    median_table = pd.DataFrame(median_table, index=index, columns=stats.keys())
    total_table = pd.DataFrame(total_table, index=index, columns=stats.keys())
    with open(output, 'w') as f:
        f.write('Median time per iter, sec')
        f.write('\n')
        f.write(median_table.to_string())
        f.write('\n')
        f.write('Total time, sec')
        f.write('\n')
        f.write(total_table.to_string())
        f.write('\n')