Alle Neu

user:thomas Gists erstellt von Nutzer

title:mygist Gists mit Titel

filename:myfile.txt Gists mit Dateinamen

extension:yml Gists mit Dateiendung

language:go Gists in Sprache

topic:homelab gists with given topic

Anmelden


Alle Neu Anmelden

All gists matching topic profiling

Neueste erstellt
Älteste erstellt
Neueste bearbeitet
Älteste bearbeitet

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

0 Favoriten
0 Forks
1 Dateien
Zuletzt aktiv 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() # 呼叫函式
Neuer Älter

Powered by Opengist ⋅ Load: 27ms⋅

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