Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] [MOVED]Question about code execution time

Status
Not open for further replies.

romel_emperado

Advanced Member level 2
Joined
Jul 23, 2009
Messages
606
Helped
45
Reputation
132
Reaction score
65
Trophy points
1,318
Location
philippines
Activity points
6,061
Hi all,

is there any tool or you can suggest an IDE to me where I can measure the execution time of a simple instruction.

I want to test which is more faster of these two..

PHP:
a = a + b;
PHP:
c = a+b;
 

Re: Question about code execution time

If you look at the runtime of only a=a+b or c=a+b, they should be the same as long as the CPU has ADD instruction that can specify the same register for source and destination(which is probably true to almost any processors).

But if you look at the run time of overall program that contains a=a+b, or c=a+b, the latter CAN be slower in case that the register for c is occupied by other data and the CPU needs to access the memory before executing c=a+b. It depends on the overall activity in the CPU and programming.
 
Re: Question about code execution time

okay..Thanks..

does the MPLAb IDE has the feature of measuring the execution time?
 

Re: Question about code execution time

Usually the IDE tool has an integrated simulator, you can use a breakpoints to stop execution before the line you want to measure, reset the watch and cycle counter and step execute until the point you want and check the counters.
An alternative would be to see the ASM instructions output of your code, measure the instructions and compare them or multiply them with the time it takes for one instruction to execute (which depends on the architecture of the mcu) to calculate the execution duration.

Alex
 
Re: Question about code execution time

Another more rudimentary method is simply to count the number of instructions required to perform the task in the assembly listing or disassembly view.

Most compilers either create an assembly listing by default or have the option to do so.

For example here is a snippet from a PIC16F877A C program's assembly listing:

532 ;serial.c: 62: c = (c >> 1) | 0x80;
533 07FA 1403 setc
534 07FB 0CF2 rrf putch@c,f

The C statement "c = (c >> 1) | 0x80;" compiles into the following two assembly instructions, both of which require one instruction cycle for execution.

BigDog
 
Re: Question about code execution time

does the MPLAb IDE has the feature of measuring the execution time?
Yes, the MPLAB simulator has a stopwatch to measure execution time.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top