Question on measuring execution speed
Archiver
Posts: 46,084
I was trying to find information in the archives on code that would
measure the time a routine took to execute. An internal stop watch if
you will. Haven't been sucessful. Can anyone point me in the right
direction?
measure the time a routine took to execute. An internal stop watch if
you will. Haven't been sucessful. Can anyone point me in the right
direction?
Comments
khufumen@y... writes:
I was trying to find information in the archives on code that would
measure the time a routine took to execute. An internal stop watch if
you will. Haven't been sucessful. Can anyone point me in the right
direction?
There may be code that measures the time of a loop, but I am unaware of such.
If there are not many IF statements, a method that will get you close is to
bracket your section of code by making a pin go high just before the section
you want to measure, then go low imeadiately after. Then with an oscope meausure
that time.
Also, this link has execution times of individual
[url=instructions...http://www.emesystems.com/BS2speed.htm]instructions...http://www.emesystems.com/BS2speed.htm[/url]
[noparse][[/noparse]Non-text portions of this message have been removed]
very simply: On entering the code (routine) you want to time, set your
spare pin high; when the code is done take the spare pin back low. On
your second Stamp, use PULSIN to measure the spare pin pulse duration.
I've done this many times, converted the PULSIN value to milliseconds
and displayed on a Scott Edwards serial LCD.
I recently used this to time subroutines in a small robot so that I
could update the servos when needed, and not kill time unnecessarily
with PAUSE. At the end of each subroutine I had this kind of line:
tix = tix + measured_routine_time_in_ms
The top of my control code looked like this:
Main:
IF (tix >= 20) THEN GOSUB Update_Servos
ON state GOSUB Task_0, Task_1, ...
...
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: Eric Berg [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=IJXmoHvvolRlTBAjHTmhNX417tIY3raC71lS8_P5iNv4bq2l1-oCuB4UK7-qADJR--6qK-lO7q9G6A]khufumen@y...[/url
Sent: Sunday, December 21, 2003 11:10 AM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Question on measuring execution speed
I was trying to find information in the archives on code that would
measure the time a routine took to execute. An internal stop watch if
you will. Haven't been sucessful. Can anyone point me in the right
direction?
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/basicstamps/
To unsubscribe from this group, send an email to:
basicstamps-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....
jwilliams@p... writes:
If you have an extra pin on your project and a second Stamp you do it
very simply: On entering the code (routine) you want to time, set your
spare pin high; when the code is done take the spare pin back low. On
your second Stamp, use PULSIN to measure the spare pin pulse duration.
I've done this many times, converted the PULSIN value to milliseconds
and displayed on a Scott Edwards serial LCD.
What about doing the same with a scope?
[noparse][[/noparse]Non-text portions of this message have been removed]
-- Jon Williams
-- Parallax
Original Message
From: smartdim@a... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=zOe1-_bqLPajR3cZeJLBTdUhSDN796zL-vvpD1KWmj-OGm2T4l6yGXsZNSa7eUaXJ8sQHuqmvWRQSPw]smartdim@a...[/url
Sent: Sunday, December 21, 2003 12:36 PM
To: basicstamps@yahoogroups.com
Subject: Re: [noparse][[/noparse]basicstamps] Question on measuring execution speed
In a message dated 12/21/2003 9:28:02 AM Pacific Standard Time,
jwilliams@p... writes:
If you have an extra pin on your project and a second Stamp you do it
very simply: On entering the code (routine) you want to time, set your
spare pin high; when the code is done take the spare pin back low. On
your second Stamp, use PULSIN to measure the spare pin pulse duration.
I've done this many times, converted the PULSIN value to milliseconds
and displayed on a Scott Edwards serial LCD.
What about doing the same with a scope?
[noparse][[/noparse]Non-text portions of this message have been removed]
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/basicstamps/
To unsubscribe from this group, send an email to:
basicstamps-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....
project. One is an industrial strength BS2 which basically manages
the power as well as a heater(a couple of low ohm resistors. Once the
temperature in the box is above freezing, power is given to a BS2sx
and the datalogging begins. The stamp will be outdoors in occasional
extreme cold weather conditions. I'll try the PULSIN method and the
oscilloscope method and see which one is easier. Thanks again for
your help.
Kind Regards,
Eric
--- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
wrote:
> Yep, that works too.
>
> -- Jon Williams
> -- Parallax
>
>
>
Original Message
> From: smartdim@a... [noparse][[/noparse]mailto:smartdim@a...]
> Sent: Sunday, December 21, 2003 12:36 PM
> To: basicstamps@yahoogroups.com
> Subject: Re: [noparse][[/noparse]basicstamps] Question on measuring execution speed
>
>
> In a message dated 12/21/2003 9:28:02 AM Pacific Standard Time,
> jwilliams@p... writes:
> If you have an extra pin on your project and a second Stamp you do
it
> very simply: On entering the code (routine) you want to time, set
your
> spare pin high; when the code is done take the spare pin back low.
On
> your second Stamp, use PULSIN to measure the spare pin pulse
duration.
> I've done this many times, converted the PULSIN value to
milliseconds
> and displayed on a Scott Edwards serial LCD.
>
>
> What about doing the same with a scope?
>
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the
Subject
> and Body of the message will be ignored.
>
>
> Yahoo! Groups Links
>
> To visit your group on the web, go to:
> http://groups.yahoo.com/group/basicstamps/
>
> To unsubscribe from this group, send an email to:
> basicstamps-unsubscribe@yahoogroups.com
>
> Your use of Yahoo! Groups is subject to:
> http://docs.yahoo.com/info/terms/
>
>
>
>
> This message has been scanned by WebShield. Please report SPAM to
> abuse@p...