Sort this messy list / benchmark.py

#! /usr/bin/env python
#-*- coding: utf-8 -*-

import time
import random

from fusion import Fusion
from bubble import Bubble
from selection import Selection, Selection_Better
from casier import Casier
from insertion import Insertion, Insertion_Better
from natif import Natif


class Benchmark(object):
    """
    Benchmark on sorting functions.
    """
    def __init__(self, nb_elements = [500,1000,5000,10000], nb_max = 2**64):
        """
        Initializations.
        """
        self.nb_elements = nb_elements
        self.nb_max = nb_max
        self.list = []
        self.sorting_functions = {"Fusion" : [], \
                                    "Bubble" : [], \
                                    "Selection": [], \
                                    "Selection_Better": [], \
                                    "Casier": [], \
                                    "Insertion": [], \
                                    "Insertion_Better": [], \
                                    "Natif": []}

    def run(self):
        """
        Launch the benchmark.
        """
        for nb_element in self.nb_elements:
            self.list = []
            for i in range(nb_element):
                self.list.append(random.randint(0, self.nb_max))

            for sorting_function in self.sorting_functions.keys():
                print("Sorting with", sorting_function + "...")
                list_to_sort = self.list[:]
                begin  = time.clock()
                sorting_func = globals()[sorting_function](list_to_sort)
                sorting_func.sort()
                end = time.clock()
                self.sorting_functions[sorting_function] = self.sorting_functions[sorting_function] + ["%.10f" % (end - begin)]

    def write(self):
        """
        Write results in a file.
        """
        result = self.__str__()
        file = open('result', 'w')
        file.write(result)
        file.close()

    def __str__(self):
        """
        Display the results.
        """
        table = "Algorithm"
        for i in self.nb_elements:
            table = table  + "\t\t\t\t" + str(i)
        table = table + "\n\n"
        for algo in list(self.sorting_functions.keys()):
            table = table + algo + "\t\t\t"
            table = table + "\t\t\t".join(self.sorting_functions[algo])
            table = table + "\n"
        table = table + "\nTime in seconds.\n\nMachine:\n\n"
        fich = open('/proc/cpuinfo', 'r')
        info = fich.read()
        fich.close()
        table = table + info
        return table

        

if __name__ == '__main__':
    # Point of entry in execution mode.
    #benchmark = Benchmark(nb_elements = [100, 2000], nb_max=50)
    benchmark = Benchmark()
    benchmark.run()
    #print(benchmark)
    benchmark.write()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.