473,609 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

some profiler questions

Mac
I'm writing a bunch of algorithms in Python for solving a certain class
of problems, and I was interested in doing some comparisons between
them and would like to collect various high-level runtime stats, such
as the number of invocations of certain key subroutines. I have my own
code to do this. Then just earlier today it hit me that I'm really
just profiling, albeit in a more restricted way than the "profile"
module. This got me thinking and looking deeper at "profile.py ", and
I've got some questions:

1) I'd still like to run my whole app (i.e., using main()), but I'd
like to limit the profiling to only the select few subroutines. That
is, say I have a set of such fns in mind, call it "key_fns", and I
would like to only profile # of invocations of these fns from key_fns,
as well as by whom they were called, and how much cumulative time was
spent in them. Is such lower-level control possible? The main reason
I want this is that I do not want to profile most of the low-level
routines, like vector addition, at least not yet... I don't want to
slow down code execution any more than is necessary, as the statistics
gathering should occur during "normal" runs (i.e., during normal
operation).

2) I've only just discovered that pstats has "print_callers( )"! That's
very useful info I wasn't aware was available! What I'm really looking
for now is profiler output in the style generated by "gprof", the GNU
profiler, as I have found that format terribly useful (a section for
each fn, with the fn's callers and callees interwoven in each section).
Does anyone know of a utility which would format the Python profiling
info in that format, or something very similar? I haven't actually
seen any output from print_callers (can't find any samples on Net, and
my app is currently half-busted, mid-refactor), so if that's what it
precisely does, ignore this question.

3) assuming the above-mentioned fine control of (1) is not yet
possible, I will muddle on with my own "selective" profiling code; the
question I have then is, what is the cleanest way to override a class
instance's method at runtime? What my profiler is doing is overriding
the key fns/methods of an instance with a stat-gatherer-instrumented
version, which ends up calling the original method. I tried reading
profile.py and pstats.py for ideas, but they are a little too
complicated for me, for now; I doubt that's how they do their profiling
anyways. Any way to do this in an automated fashion, given that I have
the list of method names I want to instrument in a list variable?

Jul 19 '05 #1
1 1118
"Mac" <id************ ******@yahoo.co m> writes on 7 Jun 2005 20:38:51 -0700:
....
1) I'd still like to run my whole app (i.e., using main()), but I'd
like to limit the profiling to only the select few subroutines. That
is, say I have a set of such fns in mind, call it "key_fns", and I
would like to only profile # of invocations of these fns from key_fns,
as well as by whom they were called, and how much cumulative time was
spent in them. Is such lower-level control possible? The main reason
I want this is that I do not want to profile most of the low-level
routines, like vector addition, at least not yet... I don't want to
slow down code execution any more than is necessary, as the statistics
gathering should occur during "normal" runs (i.e., during normal
operation).
Please read the "How it works section".

You find an example how the profiler can be customized
in my "ZopeProfil er" product (the "HLProfiler.py" ).
It makes profiling slower (as it derives high level profiles
in addition to the low level ones) but might nevertheless
help you as an example.

<http://www.dieter.hand shake.de/pyprojects/zope>
2) I've only just discovered that pstats has "print_callers( )"! That's
very useful info I wasn't aware was available! What I'm really looking
for now is profiler output in the style generated by "gprof", the GNU
profiler, as I have found that format terribly useful (a section for
each fn, with the fn's callers and callees interwoven in each section).
Does anyone know of a utility which would format the Python profiling
info in that format, or something very similar? I haven't actually
seen any output from print_callers (can't find any samples on Net, and
my app is currently half-busted, mid-refactor), so if that's what it
precisely does, ignore this question.
Thus, you look at the internal representation of "pstats"
and format it in the way you like...
3) assuming the above-mentioned fine control of (1) is not yet
possible, I will muddle on with my own "selective" profiling code; the
question I have then is, what is the cleanest way to override a class
instance's method at runtime?
class_.f = some_wrapper(cl ass_.f)
What my profiler is doing is overriding
the key fns/methods of an instance with a stat-gatherer-instrumented
version, which ends up calling the original method. I tried reading
profile.py and pstats.py for ideas, but they are a little too
complicated for me, for now; I doubt that's how they do their profiling
anyways.


You should read the "How it works section".
You will find out that your doubt is justified...
Dieter
Jul 19 '05 #2

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

Similar topics

0
1877
by: Jeff Mair | last post by:
Hello all, I haven't been using profiler for a terribly long time, and I've come across something that I just can't figure out. I'm running MS Virtual PC to run a Win2K Server OS with SQL Server 2000 (sp3 i think). Whenever I start up SQL Profiler - even immediately after a bootup, if I try to pause, stop, or exit out of profiler, it hangs. The strange part is that it seems to keep on tracing even though it won't respond anymore. I...
8
2825
by: patrickshroads | last post by:
I am running a profiler trace against a database and noticed that the reads column always shows 0. When running the same trace against another machine I get back values in the reads column. I took a query that profiler reported as having 0 reads and ran in in query analyzer wtih STATISTICS IO on and confirmed that there are in fact reads: Table 'tt_cawardalloc'. Scan count 1, logical reads 8, physical reads 0, read-ahead reads 1. Table...
0
1654
by: DraguVaso | last post by:
Hi, I'm using for a while DevPartner Profiler (http://www.compuware.com/products/devpartner/resources/profiler/profiler.as p), but unfortunately it works only for 2002 and 2003. Is there a profiler that looks like DevPartner Profiler (gives the same information: shows clearly which methods/statements takes the most time in total etc and free!). Or will DevPartner make a version for 2005 soon?
4
4085
by: pnp | last post by:
Which is the best profiler for C# apps? Thanks in advance, Peter
3
1687
by: Rajko | last post by:
Does anyone know any program which could be used as profiler for programs written in .NET? Thx, Rajko.
3
1684
by: Maansi Gupta | last post by:
Platform - Windows 2000 Professional , VC .NET 7.1 Hello, I have recently ported my source code from Visual Studio 6.0 to .NET 7.1 Previously with Visual Studio 6.0 I was using the profiler in the following way 1) Build the project with link setting- Enable Profiling as checked. 2) I had created a custom batch file for profiling my application and was
5
1513
by: SharpSmith | last post by:
hi all the question is more related to architecture and practices and I'll appreciate any opinion i work with asp net 1/2 few years and with any project we developing we meet performance issues maybe the problems is our methods or maybe we do not do the right things but it seems that view state and heavy page model really make performance bad also, when you work with asp.net it very easy to start building your site component-oriented...
3
2659
by: akkha1234 | last post by:
I am using SQL Profiler to monitor one of my database. The temporary trace file is stored under C:\Documents and Settings\user \Local Settings\Temp by default. Is it possible to re-configure it to place to another location as the file become huge after some time. Thanks
1
3169
by: ofirmgr | last post by:
im trying to understand how the profiler works. so i started 2 profilers,one listen to another and I saw the profiler is running: exec sp_trace_create @P1 output, 1, NULL, NULL, NULL which means @tracefile = NULL so where from the profiler read the results?!
0
8145
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...
1
8236
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
7030
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6068
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5526
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4037
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...
1
2541
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1690
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1407
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.