View previous topic :: View next topic |
Author |
Message |
jseidmann
Joined: 04 Nov 2004 Posts: 67
|
How to check how long code takes to run? |
Posted: Fri Jan 07, 2005 4:25 pm |
|
|
Hi, I wanted to know what ways there are to find out how long a section of code will take to run. I have an EEPROM connected and can store that time value in it to access later on. Is there a command that can store the time delayed between two points? What means have all of you used to see how long your code takes to execute some portion?
Jon |
|
 |
NikkiC
Joined: 21 Jun 2004 Posts: 3 Location: London, UK
|
|
Posted: Fri Jan 07, 2005 5:25 pm |
|
|
Three ways: using an oscilloscope, using the simulator in MPLAB or simply counting the number of clock cycles required to execute any chunk of code.
Nikki |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
 |
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Sat Jan 08, 2005 10:49 pm |
|
|
Set up a timer interrupt. Count the interrupts in the ISR. Sample the counter before and after the code of interest executes (assumption: code of interest is not inside another ISR). Calculate the difference of the counter and store it in the EEPROM.
Nick |
|
 |
|