Všechno Nové

user:thomas gists created by user

title:mygist gists with given title

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

Přihlásit se


Všechno Nové Přihlásit se

All gists matching topic timing

Nedávno Vytvořeno
Nejméně nedávno Vytvořeno
Nedávno Aktualizováno
Nejméně nedávno Aktualizováno

timmy / 使用 funcy 裝飾器測量函式執行時間

0 Lajky
0 Forky
1 Soubory
Naposledy aktivní 10 months ago
這段程式碼使用 funcy 模組的 print_durations 裝飾器,測量並印出 func 函式的執行時間,範例中透過簡單的迴圈模擬運算過程。
benchmarking decorator funcy performance profiling python timing
1 from funcy import print_durations # 匯入 funcy 模組中的 print_durations 裝飾器
2
3 @print_durations # 裝飾器:用於計算函式執行時間並印出
4 def func():
5 """一個範例函式,使用範例裝飾器 print_durations 來印出其執行時間。"""
6 for i in range(10000): # 進行一個範例的迴圈計算
7 pass
8
9 func() # 呼叫函式
Novější Starší

Vytvořeno pomocí Opengist ⋅ Load: 27ms⋅

Čeština
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文