Skip to content

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

@crimsonaltima

Description

@crimsonaltima

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 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions