Hi. Is it possible to find out how long it takes to run a certain block of code?
Hi. Is it possible to find out how long it takes to run a certain block of code?
Yes indeed!
at least 3 method
- use MPLAB sim or else simulator
- toggle a led and measure it with a scope
- use a PIC timer and show it on LCD or via SerialComm
i like the Timer option as it measure the real stuff in a real environment. Have a look at the followings
instruction execution time
http://www.picbasic.co.uk/forum/showthread.php?t=365
Now a collection of pretty nice and usefull tools...
- Embedded Strings in your Code Space
- While we're on the subject of optimization...
- The EXT (external) modifier.
- How much code would a code hog hog
- instruction execution time
Example how to mix them all together...
The Best Solution post #9
http://www.picbasic.co.uk/forum/show...33&postcount=9
The Best Solution --- The whole thread
http://www.picbasic.co.uk/forum/show...ht=stuff+handy
Once again... Thanks Darrel!
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Hi,
You have a couple of options:
** Run it and time it in the simulator in MPLAB.
** Set a pin high when you enter the code section and low when you exit it. Look at the output with an oscilloscope.
** Use one of the PIC's timers to measure the execution time. Start it when you enter the section of code and stop it when you exit it. Someone (Darrel perhaps??) posted some code that was perfect for that but I can't seems to find it right now. I'll take another look.
/Henrik Olsson.
EDIT: OK Steve beat me to it. With nicer layout AND links to the code I was thinking about, and then some....
Last edited by HenrikOlsson; - 21st November 2007 at 06:38.
even much funny, you said it in same order as me
![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Oh stop,
You're making me blush.
EDIT: What am I saying ??
Bring it on.<br>
Last edited by Darrel Taylor; - 21st November 2007 at 08:25. Reason: WooHoo.
DT
Wow. Thats a lot of stuff to be looking at. An oscilloscope is deffo out because i dont have one and i think they are expensive. Ive never used the simulator before but im guessing it runs on the PC and could be affected by other programs that are running. I will try out the timer method because it seems best. Ive just gotta have a good read through those links to find out how to use one.
Thanx for the optimization bits too. I like things to be as optimized as possible.
Bookmarks