GoogleCloudPlatform / GoogleCloudPlatform/cloud-profiler-python

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

Aperta
#134 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
question
Lingua principale
Python
Stelle
32
Fork
35
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.