Q: When using CodeWarrior for StarCore, what is the meaning of the clock() function's return value when running MSC8144 for ISS ?
When using CodeWarrior for StarCore, what is the meaning of the clock() function's return value when running MSC8144 for ISS? I tried to use the code found in StarCore_C_Compiler_User_Guide.pdf to measure the time needed for my application processing:
#include "time.h"
clock_t start, end, elapsed;
/* . . . application setup . . . */
start = clock( );
/* . . . application processing . . . */
end = clock( );
elapsed = end - start; /* Assumes no wrap-around */
printf("Elapsed time: %Lu * 2 cycles. \n", elapsed);
I want to know that is the meaning of the number returned by clock()? Is it my CPU's clock, or the core's internal clock?
A: The time shown when running the MSC8144 for ISS represents the number of instructions executed. Each time a new instruction is executed, the SC100 Simulator Register/CYCLE is incremented. When the clock() function is called, the Debugger Engine automatically reads the value of the CYCLE register.
In order to measure the time needed for code execution via clock(), you need to use one of the MSC8144 timers. For a proper measurement, the timer needs to be initialized and started. An example about how to achieve this can be found in: {CW install dir}\StarCore_Support\MiniDrivers_8144ADS\Examples\CoreTimer\.
Please notice that you need to add libd, (located in {CW Install dir}\StarCore_Support\MiniDrivers_8144ADS\Lib\) to your project in order to have the proper implementation of the clock() function.
The workstation CPU's speed has no influence upon clock()'s return value.