How to determine how long your program take?

Hi, guys! I got a problem.
I had written a program in C51, but i don't know to calculate the time taken for this whole program. Is there any way to calculate my program ?
Thank you!!!

Parents
  • Run it in the simulator and use the performance analyzer.

    Start a timer at the beginning, read it at the end.

    If the program takes longer than the timer can represent, write an interrupt handler to count timer ticks, and add the fraction of a tick that's left over at the end.

    If the program takes human-scale times and precision isn't an issue, just use a stopwatch.

    Toggle an I/O pin at the start and end and use a logic analyzer to measure the times between pulses.

    Send a character out the UART, and time it on your PC. Don't forget it'll take a millisecond to transmit at 9600 bps. Check the accuracy of the timers in your OS, too.

Reply
  • Run it in the simulator and use the performance analyzer.

    Start a timer at the beginning, read it at the end.

    If the program takes longer than the timer can represent, write an interrupt handler to count timer ticks, and add the fraction of a tick that's left over at the end.

    If the program takes human-scale times and precision isn't an issue, just use a stopwatch.

    Toggle an I/O pin at the start and end and use a logic analyzer to measure the times between pulses.

    Send a character out the UART, and time it on your PC. Don't forget it'll take a millisecond to transmit at 9600 bps. Check the accuracy of the timers in your OS, too.

Children
More questions in this forum