Notice: file_put_contents(): Write of 18154 bytes failed with errno=28 No space left on device in /var/www/tgoop/post.php on line 50
Proglib.academy | IT-курсы@proglib_academy P.2637
PROGLIB_ACADEMY Telegram 2637
🕒 Как замерить время выполнения алгоритма в Python

Хочешь понять, насколько быстро работает твой код. Тогда без точных замеров тут не обойтись. Показываем 3 способа, как правильно мерить время выполнения в Python — от простого к более точному:

1️⃣ time.time() — простой и быстрый

import time

start = time.time()
# твой код
end = time.time()

print(f"Время выполнения: {end - start:.4f} сек.")


2️⃣ time.perf_counter() — для высокой точности

import time

start = time.perf_counter()
# твой код
end = time.perf_counter()

print(f"Время выполнения: {end - start:.6f} сек.")


3️⃣ timeit — встроенный модуль для честных замеров

import timeit

print(timeit.timeit("x = [i for i in range(1000)]", number=1000))


🔵 Чтобы знать об алгоритмах все, забирайте наш курс «Алгоритмы и структуры данных»

Proglib Academy #буст
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥3



tgoop.com/proglib_academy/2637
Create:
Last Update:

🕒 Как замерить время выполнения алгоритма в Python

Хочешь понять, насколько быстро работает твой код. Тогда без точных замеров тут не обойтись. Показываем 3 способа, как правильно мерить время выполнения в Python — от простого к более точному:

1️⃣ time.time() — простой и быстрый

import time

start = time.time()
# твой код
end = time.time()

print(f"Время выполнения: {end - start:.4f} сек.")


2️⃣ time.perf_counter() — для высокой точности

import time

start = time.perf_counter()
# твой код
end = time.perf_counter()

print(f"Время выполнения: {end - start:.6f} сек.")


3️⃣ timeit — встроенный модуль для честных замеров

import timeit

print(timeit.timeit("x = [i for i in range(1000)]", number=1000))


🔵 Чтобы знать об алгоритмах все, забирайте наш курс «Алгоритмы и структуры данных»

Proglib Academy #буст

BY Proglib.academy | IT-курсы




Share with your friend now:
tgoop.com/proglib_academy/2637

View MORE
Open in Telegram


Telegram News

Date: |

Select: Settings – Manage Channel – Administrators – Add administrator. From your list of subscribers, select the correct user. A new window will appear on the screen. Check the rights you’re willing to give to your administrator. Add up to 50 administrators According to media reports, the privacy watchdog was considering “blacklisting” some online platforms that have repeatedly posted doxxing information, with sources saying most messages were shared on Telegram. Some Telegram Channels content management tips Telegram is a leading cloud-based instant messages platform. It became popular in recent years for its privacy, speed, voice and video quality, and other unmatched features over its main competitor Whatsapp.
from us


Telegram Proglib.academy | IT-курсы
FROM American