This repository has been archived on 2025-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
Files
python_it_top/test_time_func.py

49 lines
1.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from time import time
from sys import exit as ex
REPET = [ 20_000, 40_000, 60_000, 80_000 ]
REPET_INDEX = int(0) # началый индекс
while True:
print("Значение repet:", REPET[REPET_INDEX]) # легкое обозначение того на какой рипит сейчас идет цикл
# Тест append
start = time()
arr = []
for _ in range(REPET[REPET_INDEX]): # указание радиуса
arr.append(5)
stop = time()
print("appd: ", stop - start)
# Тест pop(удаление последнего элемента)
start = time()
arr = []
for _ in range(REPET[REPET_INDEX]):
arr.append(5) # Без добавления элемента pop просто будет писать об отсуствии элементов в списке
arr.pop()
stop = time()
print("pop(посл): ", stop - start)
# Тест pop(удаление первого элемента)
start = time()
arr = []
for _ in range(REPET[REPET_INDEX]):
arr.append(5) # Тоже самое что и в поп где удаление последнего элемента
arr.pop(0)
stop = time()
print("pop(перв): ", stop - start)
# Тест insert
start = time()
arr = []
for _ in range(REPET[REPET_INDEX]):
arr.insert(0,5)
stop = time()
print("ins: ", stop - start)
# Добавление индекса и начало нового цикла
print("--= кон репит =--") # оповещение об закончивании первого рипита
REPET_INDEX += 1 # добавление индекса(тоесть от 0)
if REPET_INDEX == 4: # если индекс больше 3 то сделать выход из программы
ex(1) # Тоесть не выводить каждый раз трейсбак