def __init__(self):
     self.ventana = tk.Tk()
     self.ventana.geometry('500x200')
     self.ventana.resizable(0, 0)
     self.ventana.title('Cronometro')
     self.ventana.config(background='#72a922')
     self.cronometro_label = tk.Label(text="",
                                      font=('Tahoma', 44),
                                      fg='#ffffff',
                                      bg='#1f2f3f',
                                      pady=10,
                                      padx=10)
     self.cronometro_label.place(x=20, y=30)
     self.cronometro = Cronometro()
     self.activo = True
     self.frame = Frame(self.ventana)
     self.cronometro_label.configure(text=self.cronometro.mostrarTiempo())
     self.btnIniciar = Button(self.frame,
                              fg='blue',
                              text='Iniciar',
                              command=self.actualizar)
     self.btnIniciar.grid(row=1, column=1)
     self.btnParar = Button(self.frame,
                            fg='blue',
                            text='Parar',
                            command=self.parar)
     self.btnParar.grid(row=1, column=2)
     btnReiniciar = Button(self.frame,
                           fg='blue',
                           text='Reiniciar',
                           command=self.reiniciar)
     btnReiniciar.grid(row=1, column=3)
     self.frame.pack(side=tk.BOTTOM)
     self.ventana.mainloop()
示例#2
0
 def __init__(self, vista):
     self.app = vista
     self.cronometro = Cronometro()
     #self.app.btnIniciar['command'] = self.iniciar
     self.app.btnIniciar['command'] = self.interruptor
     self.app.btnReiniciar['command'] = self.reiniciar
     self.app.root.mainloop()
示例#3
0
 def __init__(self, host):
     self.__host = host
     self.__ping = Ping()
     self.__novoQuadro = None
     self.__quadroRecebido = False
     self.__quadroTempoVital = 4  # Time in seconds
     self.__quadroTTL = 64  # ttl linux defaul
     self.__cronometro = Cronometro()
     #self.__timer = [0,0] useless
     self.__enviados = 0
     self.__recebidos = 0
示例#4
0
    def __init__(self):
        super().__init__()

        self.title = 'Placar para gincanas'
        self.top = 0
        self.left = 0
        self.width = 1366
        self.height = 768

        self.valorPlacarA = 0
        self.valorPlacarB = 0

        self.initWindow()
        self.cronoWindow = Cronometro()
示例#5
0
 def configCronometro(self):
     print('Inciando cronometro')
     self.cronoWindow = Cronometro()
     self.cronoWindow.show()
def main():
    ##########################
    #         CONFIG
    ##########################
    seeds = [11,7,13,19,5189,600,1000,1500,1500,1500, 1000]
    size = [50,100,250,500,1000,1500,2000,2500,3000,3500,7000]
    epcohs = []
    ##########################
    ##########################


    ##########################
    #   RUN THE EXPERIMENTS
    ##########################
    # Throw the experiments
    for exp in range(5):
        print(f">>>> EXPERIMENTO: {exp + 1} <<<<")
        results = []
        for i,seed in enumerate(seeds):
            np.random.seed(seed)
            vetor = gera_seq_aleatoria(size[i])

            cron = Cronometro()
            
            cron.Iniciar()
            conta_somas(vetor)
            cron.Parar()

            results.append(cron.Exibir())

            print(f"Tempo gasto com {size[i]} elementos foi {cron} segundos")
            del vetor
            del cron
        
        epcohs.append(results)
        print()
    ##########################
    ##########################


    ##########################
    #    PLOT THE RESULTS
    ##########################

    # Generate the scatter X and Y
    scatter_x = size * len(epcohs)
    scatter_y = np.concatenate(epcohs)

    # Create a polinomial function of 1 dimension
    fit_fn = np.poly1d(np.polyfit(scatter_x,scatter_y,1))
    
    plt.title("Resultados")
    
    # PLOT: Linear Regression
    line, = plt.plot(scatter_x, fit_fn(scatter_x), '--', c="#0c29d0")
    line.set_dashes([10,5,10,5])

    # PLOT: Poly Regression
    plt.plot(size, np.mean(epcohs, axis=0), c="#ff5900", label="Regressão Poly")

    # PLOT: STM
    plt.fill_between(size, np.min(epcohs, axis=0), np.max(epcohs, axis=0), alpha=.3, facecolor="#ff5900", label="Desvio")
    
    # PLOT: Scatter
    plt.scatter(scatter_x, scatter_y, c="#0c29d0", label="Tempos")
    
    plt.legend(['Tendência', 'Regressão Polinomial', 'Desvio', 'Tempos'])
    
    plt.show()
def insertion_sort(array):
    for i in range(len(array)):
        current_value = array[i]
        current_position = i
        while (current_position > 0
               and array[current_position - 1] > current_value):
            array[current_position] = array[current_position - 1]
            current_position = current_position - 1
        array[current_position] = current_value
    return array


for algorithm in (insertion_sort, selection_sort):
    algorithm_name = algorithm.__name__
    for input in (10_000, 100_000, 1_000_000):
        sorted_numbers = list(range(input))
        reversed_sorted_numbers = list(reversed(sorted_numbers))
        random_numbers = sorted_numbers[:]  # copia os ordenados
        shuffle(random_numbers)  # embaralha eles

        with Cronometro(f"{algorithm_name} com entrada" +
                        f"ordenada de {input} números"):
            algorithm(sorted_numbers)
        with Cronometro(f"{algorithm_name} com entrada" +
                        f"inversamente ordenada de {input} números"):
            algorithm(reversed_sorted_numbers)
        with Cronometro(f"{algorithm_name} com entrada" +
                        f"aleatória de {input} números"):
            algorithm(random_numbers)

        print("*" * 50)
示例#8
0
def merge(left, right, merged):
    left_cursor, right_cursor = 0, 0

    while left_cursor < len(left) and right_cursor < len(right):

        if left[left_cursor] <= right[right_cursor]:
            merged[left_cursor + right_cursor] = left[left_cursor]
            left_cursor += 1
        else:
            merged[left_cursor + right_cursor] = right[right_cursor]
            right_cursor += 1

    for left_cursor in range(left_cursor, len(left)):
        merged[left_cursor + right_cursor] = left[left_cursor]

    for right_cursor in range(right_cursor, len(right)):
        merged[left_cursor + right_cursor] = right[right_cursor]

    return merged


for algorithm in (bubble_sort, merge_sort):
    algorithm_name = algorithm.__name__

    numbers = list(range(10_000))
    shuffle(numbers)

    with Cronometro(algorithm_name):
        algorithm(numbers)
示例#9
0
        array[current_position] = current_value

    return array


# algorithms execution
for algorithm in (insertion_sort, selection_sort):
    algorithm_name = algorithm.__name__

    for input in (10_000, 100_000, 1_000_000):

        sorted_numbers = list(range(input))
        reversed_sorted_numbers = list(reversed(sorted_numbers))
        random_numbers = sorted_numbers[:]  # copia dos ordenados
        shuffle(random_numbers)  # embaralha eles

        with Cronometro(
                f"{algorithm_name} com entrada ordenada de {input} números"):
            algorithm(sorted_numbers)

        with Cronometro(
                f"{algorithm_name} com entrada inversamente ordenada de {input} números"
        ):
            algorithm(reversed_sorted_numbers)

        with Cronometro(
                f"{algorithm_name} com entrada aleatória de {input} números"):
            algorithm(random_numbers)

        print("*" * 50)
示例#10
0
from Cronometro import Cronometro

with Cronometro("algoritmo"):
    animais = [
        "zebra", "macaco", "elefante", "arara", "javali", "cabra", 'boy',
        'bode'
    ]
    animais.sort()
    print(animais)