Scalene - accumulative memory vs instant memory #265
-
Scalene is really a super useful tool - thanks to the author! I wanted to discuss clarity around accumulative memory vs instant memory. See Sample code below. When looped once, scalene profiles the functions using 4GB. When looped 5 times, scalene profiles the function as using 20GB (which is accumulative). is there a way to get the max instant (aka 4GB) from the profile without only running the loop once?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
It's not currently possible in Scalene. Here's why. The only approach I am aware of is counting lines via |
Beta Was this translation helpful? Give feedback.
It's not currently possible in Scalene. Here's why. The only approach I am aware of is counting lines via
https://docs.python.org/3/library/sys.html#sys.settrace
. In my tests, this can slow down pure Python execution by almost 10x, which makes it a dealbreaker as a default. On the other hand, for programs like the one above that make extensive use of native modules like numpy and Pandas, the overhead is negligible, so it could be optionally activated.