On Wednesday, April 22, 2015 at 10:20:58 PM UTC+5:30, Ganesh Pal wrote:
> Thank you , this answers my question : )
Hi, Thanks for asking this question, it introduced me to the timeit module.
Just a friendly, next time refrain yourself from top posting.
Cheers!
--
https://mail.python.org/mai
Thank you , this answers my question : )
On Apr 22, 2015 6:39 PM, "Michael Torrie" wrote:
>
> On 04/21/2015 09:31 PM, Ganesh Pal wrote:
> > Iam not able to understand what why only 10 loops were run ? what
> > does this mean and how does this work ?
>
> I have a hunch you're mistakenly thinkin
On Wed, Apr 22, 2015 at 7:07 AM, Michael Torrie wrote:
> I have a hunch you're mistakenly thinking that Python is only running
> through ten iterations of your for i in range(100) loop. This is
> not the case. The entire thing is running (all 100 iterations of
> your loop), but is run te
On 04/21/2015 09:31 PM, Ganesh Pal wrote:
> Iam not able to understand what why only 10 loops were run ? what
> does this mean and how does this work ?
I have a hunch you're mistakenly thinking that Python is only running
through ten iterations of your for i in range(100) loop. This is
not
Ganesh Pal writes:
> Iam running the below command on Linux machine have Python 2.7
> installed ,
If it hasn't already been said: You should be targeting Python 3
wherever possible (with the ‘python3’ command).
Since you're not in this case – and you are specifically testing Python
2 features –
Hi Team,
Iam running the below command on Linux machine have Python 2.7
installed , I was trying to figure out the speed difference between
xrange and range functions.
range :
python -m timeit 'for i in range(100):' ' pass'
10 loops, best of 3: 90.5 msec per loop
$ python -m timeit 'for i
.25)**2 + 1 if x < 0.5 else 16*(x-0.75)**2 - 1
> --
>
> then i used module timeit to compare its execution time with math.sin()
> I put the sinusLite() function in a module named test.
>
> then:
>
>>>> import timeit
>>>> t1
+ 1 if x < 0.5 else 16*(x-0.75)**2 - 1
> --
>
> then i used module timeit to compare its execution time with math.sin()
> I put the sinusLite() function in a module named test.
>
> then:
>
>>>> import timeit
>>>> t1 = timeit.Ti
)**2 + 1 if x < 0.5 else 16*(x-0.75)**2 - 1
> --
>
> then i used module timeit to compare its execution time with math.sin()
> I put the sinusLite() function in a module named test.
>
> then:
>
>>>> import timeit
>>>> t1 = t
f x < 0.5 else 16*(x-0.75)**2 - 1
> --
>
> then i used module timeit to compare its execution time with math.sin()
> I put the sinusLite() function in a module named test.
>
> then:
>
>>>> import timeit
>>>> t1 = timeit.Timer("y=test.s
eit to compare its execution time with math.sin()
I put the sinusLite() function in a module named test.
then:
import timeit
t1 = timeit.Timer("y=test.sinusLite(0.7)", "import test")
t2 = timeit.Timer("y=math.sin(4.39)", "import math")
On 23-7-2014 17:50, Orochi wrote:
> I want a timer to calculate the execution time of the program
> actually I am trying to solve problems on codechef.com and want to find out
> the time and memory taken by the program to execute.
>
> I know we can import time.time() in unix and
I want a timer to calculate the execution time of the program
actually I am trying to solve problems on codechef.com and want to find out the
time and memory taken by the program to execute.
I know we can import time.time() in unix and time.clock() in windows
also there is a library timeit
Tim Daneliuk writes:
> Is there some standard Pythonic way to bound how long a function
> call can run, after which time it is forcefully terminated?
Basically, run it in a separate process and use os.kill to kill it.
--
http://mail.python.org/mailman/listinfo/python-list
I am writing some paramiko-based ssh routines. One of them logs into
a remote server and then does a sudo command. The problem is that if
the user provides the incorrect sudo password, the call hangs the other
end is waiting for the correct password to be entered.
Is there some standard Pythoni
Nick Craig-Wood wrote:
> ...
import signal, os, time
...
importing os is useless of course...
--
http://mail.python.org/mailman/listinfo/python-list
Nick Craig-Wood wrote:
superpollo wrote:
> ...
Or if you are on unix you can use signals...
It is probably just about acceptable to raise an exception in a signal
handler like this code does.
> ...
neat!
--
http://mail.python.org/mailman/listinfo/python-list
2009/7/16 superpollo :
> hello.
>
> based upon previuos suggestions, i tried to write a program in which i would
> like to have a certain code fragment to execute only for a specified amount
> of time (say 3 seconds), then bail out.
>
> but i get the following:
>
> $ cat tmr004.py
> #!/usr/bin/pyth
superpollo wrote:
> Diez B. Roggisch wrote:
> > superpollo wrote:
> >>am i wrong?
> >
> >
> > No, you are right, for threads that is. You can try & trick around with the
> > trace-functionality of python, and some ctypes-based
> > system-thread-module-tricks that are, as mentioned before, black
Diez B. Roggisch wrote:
superpollo wrote:
am i wrong?
No, you are right, for threads that is. You can try & trick around with the
trace-functionality of python, and some ctypes-based
system-thread-module-tricks that are, as mentioned before, black-magic & a
spinning gatling gun pointed to you
superpollo wrote:
> Diez B. Roggisch wrote:
>> superpollo wrote:
>>>see? the while body ran for about 7 seconds... i bet it has to do with
>>>the fact that the timer does not control inner loops... any suggestion?
>>
>>
>> Of course the inner loop isn't affected by the set event - how should it
Diez B. Roggisch wrote:
superpollo wrote:
see? the while body ran for about 7 seconds... i bet it has to do with
the fact that the timer does not control inner loops... any suggestion?
Of course the inner loop isn't affected by the set event - how should it be,
if you don't check it.
if you
Diez B. Roggisch wrote:
> superpollo wrote:
>
>> hello.
>>
>> based upon previuos suggestions, i tried to write a program in which i
>> would like to have a certain code fragment to execute only for a
>> specified amount of time (say 3 seconds), then bail out.
>>
>> but i get the following:
>>
Diez B. Roggisch wrote:
What you can't achieve in python without major black magic hackery that is
very dangerous is to terminate a thread while it is executing. Termination
has to be co-operative.
i see. thanks a lot.
bye
--
http://mail.python.org/mailman/listinfo/python-list
superpollo wrote:
> hello.
>
> based upon previuos suggestions, i tried to write a program in which i
> would like to have a certain code fragment to execute only for a
> specified amount of time (say 3 seconds), then bail out.
>
> but i get the following:
>
> $ cat tmr004.py
> #!/usr/bin/pytho
On Thu, Jul 16, 2009 at 6:34 PM, superpollo wrote:
> hello.
>
> based upon previuos suggestions, i tried to write a program in which i
> would like to have a certain code fragment to execute only for a specified
> amount of time (say 3 seconds), then bail out.
>
>
> see? the while body ran for
hello.
based upon previuos suggestions, i tried to write a program in which i
would like to have a certain code fragment to execute only for a
specified amount of time (say 3 seconds), then bail out.
but i get the following:
$ cat tmr004.py
#!/usr/bin/python -u
import threading , time
e =
Thanks Nick.
It processes 10-15 projects(i.e. 10-15 processes are started) at once. One
Zip file size is 2-3 MB.
When I used dual core system it reduced the execution time from 61 seconds
to 55 seconds.
My dual core system Configuration is,
Pentium(R) D CPU 3.00GHz, 2.99GHz
1 GB RAM
Regards
On Thu, Jan 8, 2009 at 7:31 PM, Nick Craig-Wood wrote:
(...)
> How many projects are you processing at once? And how many MB of zip
> files is it? As reading zip files does lots of disk IO I would guess
> it is disk limited rather than anything else, which explains why doing
> many at once is a
Sibtey Mehdi wrote:
> I use multiprocessing to compare more then one set of files.
>
> For comparison each set of files (i.e. Old file1 Vs New file1)
> I create a process,
>
> Process(target=compare, args=(oldFile, newFile)).start()
>
> It takes 61 seconds execution
higher execution time
On 2009-01-07, Steve Holden wrote:
>> I use multiprocessing to compare more then one set of files.
>>
>> For comparison each set of files (i.e. Old file1 Vs New file1)
>> I create a process,
>>
>> Process(target=compare, args=(oldFile,
;> Process(target=compare, args=(oldFile, newFile)).start()
> >>
> >> It takes 61 seconds execution time.
> >>
> >> When I do the same comparison without implementing
> >> multiprocessing, it takes 52 seconds execution time.
>
> > My first sugg
>>
>> It takes 61 seconds execution time.
>>
>> When I do the same comparison without implementing
>> multiprocessing, it takes 52 seconds execution time.
> My first suggestion would be: show us some code. We aren't
> psychic, you know.
I am!
He's only
Sibtey Mehdi wrote:
> Hi,
>
>
>
> I use multiprocessing to compare more then one set of files.
>
> For comparison each set of files (i.e. Old file1 Vs New file1) I create
> a process,
>
> Process(target=compare, args=(oldFile, newFile)).start()
>
>
Hi,
I use multiprocessing to compare more then one set of files.
For comparison each set of files (i.e. Old file1 Vs New file1) I create a
process,
Process(target=compare, args=(oldFile, newFile)).start()
It takes 61 seconds execution time.
When I do the same comparison without
r i in range(5)] print "random data :
>> %s" % data
>> print "result: %s" %bucket2.sort(data)
>>
>> How to write a test script which will outputs execution time for
>> bucket2.sort(data) ?
>
> Well:
>
> import time
>
> star
bucket2.sort(data)
>
> How to write a test script which will outputs execution time for
> bucket2.sort(data) ?
Well:
import time
starttime = time.time()
endtime = time.time()
print "Whatever does, it took %5.3fs to do." % (endtime - starttime)
Alternativly take a
David Hláčik a écrit :
Hi guys,
#! /usr/bin/python
import random
import bucket2
data = [ random.randint(1,25) for i in range(5)]
print "random data : %s" % data
print "result: %s" %bucket2.sort(data)
How to write a test script which will outputs execution time for
bucket2
Hi guys,
#! /usr/bin/python
import random
import bucket2
data = [ random.randint(1,25) for i in range(5)]
print "random data : %s" % data
print "result: %s" %bucket2.sort(data)
How to write a test script which will outputs execution time for
bucket2.sort(data) ?
Thanks
HI list,
I found the problem guys, when I embedded python code didn't call to
PyEval_InitThreads();
This function initialize GIL and other data structures for do a python code
thread safe. I believe the python traditional ( python name_script.py ) run
always a thread safe interpreter.
Therefore,
Hi Gabriel,
The source code for embedded mode it's the same, look this code :
_nrdigest = 0
_const_b = 20
_f = None
_signal = False
def handler_alrm(signum, frame):
global _signal
global _nrdigest
global _f
_signal = True
def try_me():
global _nrdigest
global _f
g
En Tue, 03 Jun 2008 16:58:12 -0300, Pau Freixes <[EMAIL PROTECTED]>
escribió:
Hi list,
First Hello to all, this is my and hope not end message to the list :P
This last months I have been writting a program in c like to mod_python
for
embedding python language, it's a middleware for dispat
Hi list,
First Hello to all, this is my and hope not end message to the list :P
This last months I have been writting a program in c like to mod_python for
embedding python language, it's a middleware for dispatch and execute python
batch programs into several nodes. Now I'm writing some python
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
> lin
"monkeyboy" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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 b
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
On 2006-12-04, monkeyboy <[EMAIL PROTECTED]> wrote:
> 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'
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
--
http://mail.python.org/mailman/listinfo/python-list
On 2006-12-04, monkeyboy <[EMAIL PROTECTED]> wrote:
> 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 o
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
--
http://mail.python.org/mailman/listinfo/python-list
Grant Edwards wrote:
>> You can get better resolution by using time.clock() instead of
>> time.time().
>
> Oh really? When I do it, time.clock() is worse:
on Unix, time.clock() is a tick counter; if your process is running when the
tick
interrupt arrives, the internal counter value is increment
On 2006-06-28, Pete Forman <[EMAIL PROTECTED]> wrote:
> "Fredrik Lundh" <[EMAIL PROTECTED]> writes:
> > simplest way:
> >
> > t0 = time.time()
>
> You can get better resolution by using time.clock() instead of
> time.time().
Oh really? When I do it, time.clock() is worse:
---
On 28.06.2006 10:01, Girish Sahani wrote:
> Sorry for spamming again, but please also enlighten me with some way to
> time a function i.e. to find out how much time each function takes for
> execution in a big program.
>> Hi all,
>>
>> Can anyone tell me the simplest way to do it (some code snipp
Pete Forman wrote:
> > t0 = time.time()
>
> You can get better resolution by using time.clock() instead of
> time.time().
depends on the platform, and whether you want wall time or process time.
--
http://mail.python.org/mailman/listinfo/python-list
"Fredrik Lundh" <[EMAIL PROTECTED]> writes:
> simplest way:
>
> t0 = time.time()
You can get better resolution by using time.clock() instead of
time.time().
--
Pete Forman-./\.- Disclaimer: This post is originated
WesternGeco -./\.- by myself and does no
Sorry for spamming again, but please also enlighten me with some way to
time a function i.e. to find out how much time each function takes for
execution in a big program.
> Hi all,
>
> Can anyone tell me the simplest way to do it (some code snippet that
> could be included in the program's main f
Girish Sahani wrote:
> Can anyone tell me the simplest way to do it (some code snippet that
> could be included in the program's main function) ??
simplest way:
t0 = time.time()
main()
print time.time() - t0, "seconds"
(assuming that you want to measure wall time, and that your prog
Hi all,
Can anyone tell me the simplest way to do it (some code snippet that
could be included in the program's main function) ??
Thanks,
girish
--
http://mail.python.org/mailman/listinfo/python-list
ist 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 mu
he wall clock and profile time difference to the
>>overhead of hotshot. While hotshot is miles better than the "regular"
>>profiler, it can still take a little time to profile code.
>>
>>
>
>Well, if hotshot reported a timing which is longer than the ex
me :) I understand the
difference between CPU time and time spent in the python code (even if
I was not clear in my previous post about it...). But this case does
not apply to my code, as my code is never "idled", takes 100 % of the
cpu, with no other CPU consuming task
> I would att
he 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 try to hotspot.
>
OK - first of all, as someone else has asked, what pl
In message <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] writes
>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
[EMAIL PROTECTED] writes:
>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.
t 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 try to hotspot. I just followed the
example of the python library reference, but I have some strange
results concerning cpu time. My profiling
Carl Banks wrote:
> I could, however, see myself
> using the slightly more complicated descriptor such as this (for a
> wholly different reason, though):
>
> . def call_with_open_file(filename):
> . def descriptor(func):
> . flo = open(filename)
> . try: f(flo)
> . fi
Nick Coghlan wrote:
> Anyway, if others agree that the ability to execute a suite at def
exeuction
> time to preinitialise a function's locals without resorting to
bytecode hacks is
> worth having, finding a decent syntax is the next trick :)
Workarounds:
1. Just use a freaking global, especially
On Fri, 25 Feb 2005 19:34:53 -0700, Steven Bethard <[EMAIL PROTECTED]> wrote:
>Nick Coghlan wrote:
>> Anyway, if others agree that the ability to execute a suite at def
>> exeuction time to preinitialise a function's locals without resorting to
>> bytecode hacks is worth having, finding a decent
Steven Bethard wrote:
Worth looking at is the thread:
http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/58f53fe8bcc49664/
Huh - I thought I put something in the original post saying "without resorting
to bytecode hacks", but I must have deleted it before sending the messag
Nick Coghlan wrote:
Anyway, if others agree that the ability to execute a suite at def
exeuction time to preinitialise a function's locals without resorting to
bytecode hacks is worth having, finding a decent syntax is the next
trick :)
I'm not certain how many use cases really require a full su
ce at compile time.
D'oh - "definition execution time", not compile time.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mai
Steven Bethard wrote:
So just to clarify, the issue you're trying to address is when you want
early binding like function default arguments get, but you don't want to
declare the names as function arguments?
Basically, yeah. Although I later realised I got the name of the feature I want
wrong -
72 matches
Mail list logo