CPU Utilization by a python function. Profile a function in a python script, not profiling the entire script...
I want to know how to get the CPU utilization in % of a python function.
I have already tried, psutils.cpu_percent. That gives utilization by entire script.
I want just a function's utilization.
For example:
I have a file called foo.py, in which there is a function bar().
I just want to get the % of CPU utilized by the function bar().
python python-2.7 profiling cpu resource-utilization
closed as too broad by Jean-François Fabre, jpp, Psi, DebanjanB, David M Jan 19 at 1:38
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
|
show 6 more comments
I want to know how to get the CPU utilization in % of a python function.
I have already tried, psutils.cpu_percent. That gives utilization by entire script.
I want just a function's utilization.
For example:
I have a file called foo.py, in which there is a function bar().
I just want to get the % of CPU utilized by the function bar().
python python-2.7 profiling cpu resource-utilization
closed as too broad by Jean-François Fabre, jpp, Psi, DebanjanB, David M Jan 19 at 1:38
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
use a python profiler
– Jean-François Fabre
Jan 18 at 20:09
1
Possible duplicate of How can you profile a Python script?
– Jean-François Fabre
Jan 18 at 20:09
1
That's not how CPU utilization works. If a functionfoocalls another functionbar, those functions don't share the CPU between them.
– user2357112
Jan 18 at 20:12
@Jean-FrançoisFabre tried memory profiler and line profiler and a couple of other profilers.. but they don't give utlization per function. I want to profile a function so not a duplicate.
– Paridhi
Jan 18 at 20:16
@user2357112 My bar function is in a script file foo.py, they are not two functions.
– Paridhi
Jan 18 at 20:17
|
show 6 more comments
I want to know how to get the CPU utilization in % of a python function.
I have already tried, psutils.cpu_percent. That gives utilization by entire script.
I want just a function's utilization.
For example:
I have a file called foo.py, in which there is a function bar().
I just want to get the % of CPU utilized by the function bar().
python python-2.7 profiling cpu resource-utilization
I want to know how to get the CPU utilization in % of a python function.
I have already tried, psutils.cpu_percent. That gives utilization by entire script.
I want just a function's utilization.
For example:
I have a file called foo.py, in which there is a function bar().
I just want to get the % of CPU utilized by the function bar().
python python-2.7 profiling cpu resource-utilization
python python-2.7 profiling cpu resource-utilization
edited Jan 18 at 20:18
Paridhi
asked Jan 18 at 20:01
ParidhiParidhi
14
14
closed as too broad by Jean-François Fabre, jpp, Psi, DebanjanB, David M Jan 19 at 1:38
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as too broad by Jean-François Fabre, jpp, Psi, DebanjanB, David M Jan 19 at 1:38
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
use a python profiler
– Jean-François Fabre
Jan 18 at 20:09
1
Possible duplicate of How can you profile a Python script?
– Jean-François Fabre
Jan 18 at 20:09
1
That's not how CPU utilization works. If a functionfoocalls another functionbar, those functions don't share the CPU between them.
– user2357112
Jan 18 at 20:12
@Jean-FrançoisFabre tried memory profiler and line profiler and a couple of other profilers.. but they don't give utlization per function. I want to profile a function so not a duplicate.
– Paridhi
Jan 18 at 20:16
@user2357112 My bar function is in a script file foo.py, they are not two functions.
– Paridhi
Jan 18 at 20:17
|
show 6 more comments
use a python profiler
– Jean-François Fabre
Jan 18 at 20:09
1
Possible duplicate of How can you profile a Python script?
– Jean-François Fabre
Jan 18 at 20:09
1
That's not how CPU utilization works. If a functionfoocalls another functionbar, those functions don't share the CPU between them.
– user2357112
Jan 18 at 20:12
@Jean-FrançoisFabre tried memory profiler and line profiler and a couple of other profilers.. but they don't give utlization per function. I want to profile a function so not a duplicate.
– Paridhi
Jan 18 at 20:16
@user2357112 My bar function is in a script file foo.py, they are not two functions.
– Paridhi
Jan 18 at 20:17
use a python profiler
– Jean-François Fabre
Jan 18 at 20:09
use a python profiler
– Jean-François Fabre
Jan 18 at 20:09
1
1
Possible duplicate of How can you profile a Python script?
– Jean-François Fabre
Jan 18 at 20:09
Possible duplicate of How can you profile a Python script?
– Jean-François Fabre
Jan 18 at 20:09
1
1
That's not how CPU utilization works. If a function
foo calls another function bar, those functions don't share the CPU between them.– user2357112
Jan 18 at 20:12
That's not how CPU utilization works. If a function
foo calls another function bar, those functions don't share the CPU between them.– user2357112
Jan 18 at 20:12
@Jean-FrançoisFabre tried memory profiler and line profiler and a couple of other profilers.. but they don't give utlization per function. I want to profile a function so not a duplicate.
– Paridhi
Jan 18 at 20:16
@Jean-FrançoisFabre tried memory profiler and line profiler and a couple of other profilers.. but they don't give utlization per function. I want to profile a function so not a duplicate.
– Paridhi
Jan 18 at 20:16
@user2357112 My bar function is in a script file foo.py, they are not two functions.
– Paridhi
Jan 18 at 20:17
@user2357112 My bar function is in a script file foo.py, they are not two functions.
– Paridhi
Jan 18 at 20:17
|
show 6 more comments
0
active
oldest
votes
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
use a python profiler
– Jean-François Fabre
Jan 18 at 20:09
1
Possible duplicate of How can you profile a Python script?
– Jean-François Fabre
Jan 18 at 20:09
1
That's not how CPU utilization works. If a function
foocalls another functionbar, those functions don't share the CPU between them.– user2357112
Jan 18 at 20:12
@Jean-FrançoisFabre tried memory profiler and line profiler and a couple of other profilers.. but they don't give utlization per function. I want to profile a function so not a duplicate.
– Paridhi
Jan 18 at 20:16
@user2357112 My bar function is in a script file foo.py, they are not two functions.
– Paridhi
Jan 18 at 20:17