loayn
Posts: 1
Joined: Fri Apr 29, 2016 12:21 am

python execution time

Fri Apr 29, 2016 12:46 am

Hi,

im new here. im looking into using my pi to do some data acquisition. i have a pulse train i am trying to capture and decode, the shortest pulse width is 14us. i was thinking of using one of the gpios as an interrupt and write some code to capture the time between pulses to ensure i have the entire train. i was thinking of using the time.time() function in python to do this then save all the data to a file and analyse later. im not sure if this is the best way to do what i am thinking. need some help.

User avatar
joan
Posts: 14960
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: python execution time

Fri Apr 29, 2016 4:40 am

Why not try and find out? It shouldn't take too long to set up an experiment.

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: python execution time

Fri Apr 29, 2016 4:57 am

loayn wrote: i have a pulse train i am trying to capture and decode, the shortest pulse width is 14us. ... thinking of using the time.time() function in python ...
That's about 71Khz (something less than a typical 75Khz watch crystal) ; should be totally doable... I agree with Joan, work up an experiment... lay out the maths, and then code it up/ you're not going to hurt anything, and you'll learn a ton...
marcus
:ugeek:

Aydan
Posts: 729
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: python execution time

Fri Apr 29, 2016 8:07 am

loayn wrote:i was thinking of using the time.time() function in python to do this
You should use time.clock().
time.time() gives you the current date/time which might get updated via ntp during your program runtime and you'll have a shift in your timing.
time.clock() gives you the cpu run time which is not affected by ntp syncs.
see also

Code: Select all

import time
help(time.time)
help(time.clock)
Regards
Aydan

Return to “Advanced users”