Tutti Nuovi

user:thomas utente che ha creato il gist

title:mygist titolo del gist

filename:myfile.txt nome di file nel gist

extension:yml estensione del file nel gist

language:go linguaggio del file nel gist

topic:homelab gists with given topic

Entra


Tutti Nuovi Entra

All gists matching topic benchmarking

Più recente creazione
Meno recente creazione
Più recente aggiornamento
Meno recente aggiornamento

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

0 mi piace
0 forks
1 files
Ultima volta attivo 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() # 呼叫函式
Più nuovi Più vecchi

Creato da Opengist ⋅ Load: 27ms⋅

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