簡體   English   中英

Python 配置文件:如何獲取每個單獨執行的時間(無聚合)

[英]Python profile: How to get the time for each individual execution (no aggregation)

我正在嘗試調試一個基於 python 的項目,該項目涉及對同一組函數的多次重復調用。 此代碼是 API 的一部分。

但是,隨着時間的推移,這些函數的執行時間會線性增加。 我現在需要找出導致單個請求完成的總時間增加的原因。 有沒有辦法分析 python 代碼並為每次重復調用函數的執行獲取 output?

As an abstract example: Let's say function 1 involves calls to function 1, function 2, function 3. I call function 1 10,000 times and then notice that the execution of function 1 took initially 0.5 seconds but increases to 5 seconds at the 10,000 call to它。 如何確定 function 1、function 2 或 function 3 是否導致了這種增加?

如果它在 Linux 環境中,您可以使用 Linux 性能perf tools並檢查每個 function 的周期數,按指令數,L1 緩存未命中加載並比較一個緩存,L1 緩存未命中加載,L1 緩存

在下面的示例中,您可以找到比較不同功能的示例。

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM