This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Error using clock() in DSK6713



Hello,

            I need to use the clock() function from time.h header, to capture values of time that an neural network, MLP,  takes to training, but when the program run, the output of values of times is even 0.00s. I want to know if has a especial way to use this function (like change the const CLOCKS_PER_SEC) , or if have a way to create a data of times using the Profile's Clock form CCS v3.1, to plot after using that.

            I'm posting the way that i'm using the clock() on my code:

#include <stdio.h>
#include <time.h>

int main()
{

     float time;
     int i;
     clock_t start, end;

     start = clock();
     for(i=0; i<100000; i++) {}
     end = clock();
     time = (float) (end-start)/CLOCKS_PER_SEC;
     printf("time = %.2f\n", time); 

    return 0;

Thanks,

  • Carlos,

    Welcome to the TI E2E forum. I hope you will find many good answers here
    In addition you can find some details through the TI.com documents and the TI Wiki Pages.
    Be sure to search those for helpful information and to browse for the questions others may have asked on similar topics.

    What is the value for CLOCKS_PER_SEC? It may be 600MHz and see how the results change.

    In your CCS Debug view--->Target menu, go to Clock and select Enable.
    Rerun the test to see the clock output.
    You can also customize your clock setup under the Clock option.

    Queries on clock() function are best handled by C/C++ Compiler  Forum.
    We can request this be moved to the Compiler Forum where people know about the compiler function
    support for things like this.

    In other option, the most accurate way would be to use one of the General Purpose 32-bit timers to count cycles.
    Be sure to account for the divider ratio for the timer's clock vs. the CPU clock.
    You can initialize one of the timers and either let it free-run after that or stop-clear-start-run-stop,
    whichever way fits your needs the best.

    In addition that, You can find the CSL_tscRead to get the valid time information at the below thread,
    http://e2e.ti.com/support/dsp/tms320c6000_high_performance_dsps/f/112/t/11641.aspx

  • Carlos,

    Did you find the solution on your issue?
    Are you followed the below suggestion,
    CCS Debug view--->Target menu, go to Clock and select Enable.
    Rerun the test to see the clock output.
    You can also customize your clock setup under the Clock option.