473,468 Members | 1,349 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Execution time of lines within a function

Hello,

I have a function that hotshot says is very slow. I can get the
aggregate execution time, but is there a way to get the execution time
of each line so I can find the bottleneck?

Thank you

Dec 4 '06 #1
6 1465
On 2006-12-04, monkeyboy <fs*****@lynx.neu.eduwrote:
I have a function that hotshot says is very slow. I can get the
aggregate execution time, but is there a way to get the
execution time of each line so I can find the bottleneck?
Try 'print_callees' on the stats object for your bottleneck. That
may help.

--
Neil Cerutti
Dec 4 '06 #2
Thanks Neil,

I looked at that, but maybe I don't understand the output. I was hoping
to see the cummulative time for the function and then the time
associated with each statement (line) within the function.

In the hotshot output below, I can see the function being called 100
times, which is correct, but the rest seems at too low a level for me
to understand which statements are causing the slow execution.

Any suggestions?

hw6r3.py:276(main) hw6r3.py:73(findw)(100) 26700.865
hw6r3.py:126(findphi)(100)
6153.585
hw6r3.py:173(findu)(100) 1823.852
hw6r3.py:197(findv)(100) 2392.977
numeric.py:31(zeros_like)(3)
0.072
numeric.py:286(array_str)(1)
0.677
rpc.py:545(__getattr__)(13)
0.197
rpc.py:589(__call__)(12) 51.334
rpc.py:319(putmessage) <string>:1(fileno)(12) 0.039
rpc.py:149(debug)(12) 0.126
rpc.py:236(asyncreturn) rpc.py:149(debug)(24) 0.126
rpc.py:242(decoderesponse)(12)
0.015
rpc.py:277(getresponse)(12)
48.166
Regards,

Frank

Neil Cerutti wrote:
On 2006-12-04, monkeyboy <fs*****@lynx.neu.eduwrote:
I have a function that hotshot says is very slow. I can get the
aggregate execution time, but is there a way to get the
execution time of each line so I can find the bottleneck?

Try 'print_callees' on the stats object for your bottleneck. That
may help.

--
Neil Cerutti
Dec 4 '06 #3
On 2006-12-04, monkeyboy <fs*****@lynx.neu.eduwrote:
Thanks Neil,

I looked at that, but maybe I don't understand the output. I
was hoping to see the cummulative time for the function and
then the time associated with each statement (line) within the
function.

Any suggestions?
I don't think the Python Profiler goes down to that level. The
next step might be to analyze the function yourself and try to
understand why it is so slow. Post the code here and let the
readers pick it apart.
In the hotshot output below, I can see the function being
called 100 times, which is correct, but the rest seems at too
low a level for me to understand which statements are causing
the slow execution.
>
hw6r3.py:276(main) hw6r3.py:73(findw)(100) 26700.865
Is this the print_callees output?

--
Neil Cerutti
Dec 4 '06 #4
The output was from print_callees(). It appears as though print_stats()
and print_callees() return the same data, just in a different
orangization. There is supposed to be a "lineevents=1" option in
hotshot.Profile, for line timings, but it doesn't seem to work in
Python 2.4.

Thanks for your help

Neil Cerutti wrote:
On 2006-12-04, monkeyboy <fs*****@lynx.neu.eduwrote:
Thanks Neil,

I looked at that, but maybe I don't understand the output. I
was hoping to see the cummulative time for the function and
then the time associated with each statement (line) within the
function.

Any suggestions?

I don't think the Python Profiler goes down to that level. The
next step might be to analyze the function yourself and try to
understand why it is so slow. Post the code here and let the
readers pick it apart.
In the hotshot output below, I can see the function being
called 100 times, which is correct, but the rest seems at too
low a level for me to understand which statements are causing
the slow execution.


hw6r3.py:276(main) hw6r3.py:73(findw)(100) 26700.865

Is this the print_callees output?

--
Neil Cerutti
Dec 4 '06 #5
"monkeyboy" <fs*****@lynx.neu.eduwrote in message
news:11**********************@n67g2000cwd.googlegr oups.com...
Hello,

I have a function that hotshot says is very slow. I can get the
aggregate execution time, but is there a way to get the execution time
of each line so I can find the bottleneck?

Thank you
The PythonDecoratorLibrary page on the Python wiki has a link to a @profile
decorator, that I have used to profile the contents of targeted functions
(only just now, I don't seem to be able to get to the wiki to get the exact
link).

-- Paul
Dec 4 '06 #6
On Dec 4, 2006, at 11:36 PM, Paul McGuire wrote:
The PythonDecoratorLibrary page on the Python wiki has a link to a
@profile
decorator, that I have used to profile the contents of targeted
functions
(only just now, I don't seem to be able to get to the wiki to get
the exact
link).
http://mg.pov.lt/blog/profilehooks-1.0.html

Note that the license has been changed from GPL to MIT, making it
distributable with non-GPL projects.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com
Dec 7 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: satish | last post by:
Hello all, I have a shared object executable viz. *cable* which I execute as follows : $ ansyscust71 -custom cable -p ANSYSRF **ansyscust71 is a shell script and is a part of a software...
38
by: vashwath | last post by:
Might be off topic but I don't know where to post this question.Hope some body clears my doubt. The coding standard of the project which I am working on say's not to use malloc.When I asked my...
10
by: greenb | last post by:
Our asp.net web app uses a .NET component (DLL) in the bin directory to call several stored procedures back to back to perform updates. They don't return any data. Sometimes the total execution...
12
by: Crirus | last post by:
I need to measure how long a function take to execute... or a sequence of code within -- Ceers, Crirus ------------------------------ If work were a good thing, the boss would take it all...
17
by: romixnews | last post by:
Hi, I'm facing the problem of analyzing a memory allocation dynamic and object creation dynamics of a very big C++ application with a goal of optimizing its performance and eventually also...
40
by: kavi | last post by:
Hello friends, Could any one tell the way of calculating the speed of c program execution?
11
by: Joseph S. | last post by:
Hi all, how do I avoid typing the keyword "$this->" every time I need to reference a member of a class inside the class? (coming from a world of cozy auto-complete enabled Java / .Net IDEs I...
18
by: Tom Cole | last post by:
I'm working on a small Ajax request library to simplify some tasks that I will be taking on shortly. For the most part everything works fine, however I seem to have some issues when running two...
0
by: Arno Stienen | last post by:
Perhaps I should be a bit more specific. When using this code to connect to a remote XML-RPC server (C++, xmlrpc++0.7 library): import xmlrpclib server =...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.