GoogleCloudPlatform / GoogleCloudPlatform/cloud-profiler-python

[Wall time] Google Cloud Profiler Strange Behavior With Python time.sleep()

未关闭
#134 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
question
主要语言
Python
星标
32
派生
35
PR 合并指标
30 天内没有已合并 PR

描述

I have been experimenting with Google Cloud Profiler and Python.

I wanted to know if it was a reliable way to measure how long a function takes to run that contains sleep commands.

I have a gist with 3 sample scripts with slight variations. Mostly the same with differing wait times. The last is similar to the second except in the main loop it calls step1 multiple times at the end.
https://gist.github.com/crimsonaltima/402b41ee23be20491d73f97832c0c017

Running these, produce the following results.
Seq1
Screen Shot 2023-03-28 at 3 24 37 PM

Seq2
Screen Shot 2023-03-28 at 3 24 21 PM

Seq3
Screen Shot 2023-03-28 at 3 24 48 PM

One thing I find odd about the profiler is that it shows a max duration of 10 seconds. Despite some functions sleeping for over 25 seconds. Is there an explanation for this?
While the bar sizes are accurate relative to their sleep time, it does not show exactly how long a function takes.

A second question, in [mainseq3.py](https://gist.github.com/crimsonaltima/402b41ee23be20491d73f97832c0c017#file-mainseq3-py) I call step 1 multiple times and noticed that all the steps1s were merged into a single bar and there is no distinction as for if this was the first call to step1 or a latter. Is that expected behavior?

A lesser question I have is does time.sleep(...) have odd effects on the profiler? I noticed the script with the really long sleep times took a very long time to begin uploading data to google cloud profiler.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。