473,322 Members | 1,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Sample code for Profiler

440 256MB
Hi,

Could anybody help me in getting the Sample code ,how to use the Profiler in Python applications.


Thanks in adavance
PSB
Apr 9 '07 #1
2 1485
Sushi
19
I couldnt help with your other questions but I thought I might try to help with this.

I wasnt entirely sure what you meant but thought this website might help:
http://www.onlamp.com/pub/a/python/2005/12/15/profiling.html

or the page from the python library site:
http://docs.python.org/lib/profile.html

sorry if I completely misunderstood what you wanted!
Apr 10 '07 #2
This is a very basic example which demonstrates the python profiler:

Expand|Select|Wrap|Line Numbers
  1. import profile
  2.  
  3. def counterTest():
  4.     """Count from 1 to 100000 using the
  5.     append instruction
  6.     """
  7.     Counter = []
  8.     for i in range(100000):
  9.                 Counter.append(i)
  10.     return Counter
  11.  
  12. print "Profile for counterTest, print the CPU time it took to count from 1 to 100000\n"
  13. profile.run('counterTest()')
The output looks like:

Profile for counterTest, print the CPU time it took to count from 1 to 100000

100005 function calls in 1.226 CPU seconds

Ordered by: standard name

ncalls tottime percall cumtime percall filename:lineno(function)
100000 0.549 0.000 0.549 0.000 :0(append)
1 0.012 0.012 0.012 0.012 :0(range)
1 0.000 0.000 0.000 0.000 :0(setprofile)
1 0.009 0.009 1.225 1.225 <string>:1(?)
1 0.656 0.656 1.216 1.216 prof_example.py:3(counterTest)
1 0.000 0.000 1.226 1.226 profile:0(counterTest())
0 0.000 0.000 profile:0(profiler)
Apr 12 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
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...
8
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...
0
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...
4
by: pnp | last post by:
Which is the best profiler for C# apps? Thanks in advance, Peter
1
by: Mikey | last post by:
Can somebody tell me what happened to the Source Profiler? It used to be under the Build menu in VC6, but now it's gone, and I cannot find anything in the docs that say what happened to it. The...
3
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...
1
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...
2
by: Paul Ritchie | last post by:
A few years ago I used a Profiler (I forget the name) on my Delphi code at the time and got fantastic results showing both: a) lines of code that took the longest to execute and b) lines of code...
0
by: anweshadash | last post by:
Using SQL Profiler: (Ref: http://msdn2.microsoft.com/en-us/library/ms181091.aspx) Sometimes it’s very beneficial to use sql profiler. Let’s have an idea about that and how to use that by...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.