473,769 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

profiling a C++ python extension

I have used gprof to profile stand alone C++ programs. I am also
aware of pure python profilers. However, is there a way to get
profile information on my C++ functions when they are compiled in a
shared library (python extension module) and called from python. From
what I can tell, gmon.out will not be generated unless the entire
executable (python interpreter) was compiled with -pg. Is my only
solution to recompile the python interpreter with -pg so that my
extension module (also compiled with -pg) produces a gmon.out?

Any suggestions or tips would be helpful.

Matt

Jul 11 '07 #1
2 1590
Hi!
It doesn't suffice to compile the python interpreter with -pg, as the
module is loaded via dlopen.
I solved the problem for my case compiling an executable with embedded
python and the module itself.
I would wish, that there would be an easier way.
Best regards,
Michael

Jul 12 '07 #2
rasmus <ma*********@gm ail.comwrote:
I have used gprof to profile stand alone C++ programs. I am also
aware of pure python profilers. However, is there a way to get
profile information on my C++ functions when they are compiled in a
shared library (python extension module) and called from python.
Any suggestions or tips would be helpful.
You didn't say what platform you're using. If you're using linux and
have root access, oprofile should be able to do what you need.

-M-

Jul 12 '07 #3

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

Similar topics

4
2150
by: KefX | last post by:
Hey...as for what I'm doing with Python, look at my post "Strange Hotshot problem". To make a long story short, I'm embedding Python in order to write a plugin to a freeware music program; the plugin interfaces to the program with C++, but the plugin calls Python routines to do much (but not all) of the work. Which brings me to the problem. It's SLOW! Well, that's hardly surprising, but anyway...I'm using Psyco, and it's definitely at...
4
3849
by: Logan | last post by:
Several people asked me for the following HOWTO, so I decided to post it here (though it is still very 'alpha' and might contain many (?) mistakes; didn't test what I wrote, but wrote it - more or less - during my own installation of Python 2.3 on Fedora Core 1 Linux for a friend of mine). Anyway, HTH, L.
2
2167
by: Irmen de Jong | last post by:
Hello I haven't received any responses on my original posting, and it could very well be that it never made it to the newsgroup (because I can't find it back on my news server here). So I'm posting this again. Sorry if it *did* make it to the group.. Please consider trying my test-program that is given here and let me know how it works on your python installation. Thanks for any insight on this.
6
3752
by: cournape | last post by:
Hi there, I have some scientific application written in python. There is a good deal of list processing, but also some "simple" computation such as basic linear algebra involved. I would like to speed things up implementing some of the functions in C. So I need profiling. I first tried to use the default python profiler, but profiling my application multiplies the execution time by a factor between 10 and 100 ! So I decided to give a...
1
1473
by: Dave | last post by:
Hello All, I'm trying to profile a Python program using gprof, but I don't understand some of the results, especially what some of the functions do. For example, _moncount, mcount, _PyEval_EvalFrame <cycle X> take too much time. What are they for? Any ideas? Thank you for your help!
13
2283
by: Jens Theisen | last post by:
Hello, I want to apologise in advance for this being off topic. It's not neither A C nor a C++ question, but to profiling in general, though I my chances are best to find the answer in the C/C++ community. I have a C++ program to profile and went about it by producing large history files of calling dependencies with associated times. It is presumably similar to gprof's data format and could be converted.
2
1500
by: Andreas Røsdal | last post by:
Hi, I'm using the Python profiler to optimize a pathfinding algorithm of a game, and would like some help from someone who knows how to improve the performance of Python code. The algorithm is A-Star, and it works correctly. However, the interface that I made between the A-Star pathfinding algorithm and the map data structure is what I've found to be a bottle-neck so far. As a start, I'd like to optimize the methods with the highest...
0
1381
by: John Ling | last post by:
Hello, I have been trying to install an application which requires Python: http://chip.dfci.harvard.edu/~wli/MAT/ My environment is AIX 5.2. Below is the section of the setup that has failed, which BTW works fine on Fedora 5. I suspect it has to do with Python on AIX and/or the setup.py script. Has anyone experienced this before? MAT-2.04182006python setup.py install Found make and swig.
1
2085
by: Petr Prikryl | last post by:
Do you think that the following could became PEP (pre PEP). Please, read it, comment it, reformulate it,... Abstract Introduction of the mechanism for language extensions via modules written using other languages. Extensions of Python could be done via special interpreter extensions. From Python sources, the special modules would look like other modules, with the Python API (the key feature from
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9996
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5307
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3564
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.