import timeit REPETICION = 10000 # Establece el numero de veces que se ejecutara cada test timeit.timeit('c = 0; c += 1', number=REPETICION) timeit.timeit('uuid.uuid1().hex', 'import uuid', number=REPETICION) mkdir 'delete-after-test' timeit.timeit("(fh, name) = tempfile.mkstemp(dir='./delete-after-test/', prefix='readme-',suffix='.txt');os.close(fh);", "import os; import tempfile", number=REPETICION) timeit.timeit("'-'.join(path_completo.split('/'))", "path_completo = 'DirA/DirB/DirC/readme.txt'", number=REPETICION) timeit.timeit("f_dic['key'] = f_dic['key'] + 1 if f_dic.has_key('key') else 0; sufijo = f_dic['key'];", "f_dic = {}", number=REPETICION) import timeit_plot as tp from matplotlib import pyplot as plt %matplotlib inline functions = ['c = 0; c += 1', 'uuid.uuid1().hex', "(fh, name) = tempfile.mkstemp(dir='./delete-after-test/', prefix='readme-',suffix='.txt');os.close(fh);", "'-'.join(path_completo.split('/'))", "f_dic['key'] = f_dic['key'] + 1 if f_dic.has_key('key') else 0; sufijo = f_dic['key'];"] setup_code = ['pass', 'import uuid;', "import os; import tempfile;", "path_completo = 'DirA/DirB/DirC/readme.txt';", "f_dic = {}"] data = tp.timeit_compare(functions, range(10,101,10), setups=setup_code, number=REPETICION) tp.timeit_plot2D(data, 'list length', 'Comparacion') functions = ['c = 0; c += 1', "'-'.join(path_completo.split('/'))", "f_dic['key'] = f_dic['key'] + 1 if f_dic.has_key('key') else 0; sufijo = f_dic['key'];"] setup_code = ['pass', "path_completo = 'DirA/DirB/DirC/readme.txt';", "f_dic = {}"] data = tp.timeit_compare(functions, range(10,101,10), setups=setup_code, number=REPETICION) tp.timeit_plot2D(data, 'list lengt', 'Comparacion')