scalene
scalene copied to clipboard
Profiled submodule shows only CPU usage -- no values in Memory column
Describe the bug
I have a script main.py that imports another module, utils.py.
main.py
from utils import func1
...
I want to profile all of the functions (not just func1) in utils.py after calling main. But I don't see any output in the Memory column.
Expected behavior
I expect the rows profiled in utils.py to show values in the Memory column. I tried --profile-only 'utils', but I still don't see values in that column.
Screenshots

Desktop (please complete the following information):
- macOS Monterey
- Firefox 108.0.1
- Scalene version 1.5.16 (2022.12.08)
Unless code increases or decreases memory consumption by at least 10MB, it won't show up in a profile. It might be useful to try to run the code with memray, for example (a memory-only profiler that reports memory usage at peak point of consumption) to see what it shows. If the consumption is more than 10MB, this is a possible bug, and we'd love more info.
PS Though I doubt this makes a difference, you can always try again with the latest release (1.5.17).
@emeryberger If I run scalene on a test script which contains all the functions in utils.py, they get profiled correctly.
It seems to me that if I import a function func1 from some module, and that function calls other functions (subfunc1 and subfunc2) within the same module, then scalene does not report the memory usage of subfunc1 and subfunc2, but only the combined usage of func1 from the script I ran scalene on.
On the other hand this seems like something you would have caught so I'm wondering if I'm just using Scalene incorrectly.
I tried to make a MWE but couldn't repro:
main.py
from utils import forloop
forloop()
utils.py
def forloop():
vals = []
for i in range(100_000_000):
vals.append(i)
def expensive_fun(n):
return n**50
This returns what you'd expect:
Let me know if you'd like me to give you the actual script to run.
Definitely. If you don't want to post it here, you can send it to my e-mail account ([email protected]). Thanks in advance.
@emeryberger If I run
scaleneon a test script which contains all the functions inutils.py, they get profiled correctly.![]()
It seems to me that if I import a function
func1from some module, and that function calls other functions (subfunc1andsubfunc2) within the same module, then scalene does not report the memory usage ofsubfunc1andsubfunc2, but only the combined usage offunc1from the script I ranscaleneon.On the other hand this seems like something you would have caught so I'm wondering if I'm just using Scalene incorrectly.
For what it's worth, I also experience this. Am I also using scalene wrong, or is this an issue? Apologies for bumping an old-ish thread.
Hi @chrisstuartparry - can you try this again on the latest version of Scalene?