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.

why the clock() execution so time-consuming on EVM board

Hi, all

I encounter a really strange problem. I want to profile our algorithm on EVM C6424, and when I use the clock() function for the profiler of several functions, the execution takes really a lot of time. But when I just read the TSCH and TSCL cycle counter instead of clock() function calls, the execution seems reasonable, about one tenth of the time consumed with clock() profilers. So can anyone explain to me why the time consumption  differs so much?

By the way, I may call the clock() or read the TSCH, TSCL cycle counter 100 timers per frame, one frame corresponds to ~30ms playback.

Thanks for any reply.

BR

Touse

  • Touse,

    Having never used this specific function myself, I would suggest you set a breakpoint at one of the calls to clock() and find out what it is doing. From the breakpoint, you can do a single-step into the function and look at its instructions in the Disassembler window.

    The best option would be to use a macro for TSCH/TSCL. This will allow the optimizer to integrate those calls with the other instructions so more parallelism can be achieved.

    Regards,
    RandyP

  • Hi, RandyP

    I check the clock() function in rtslib,it just calls the HOSTclock below.

    _CODE_ACCESS clock_t HOSTclock(void)
    {
       clock_t result;
       _lock();

       writemsg(_DTGETCLK,parmbuf,NULL,0);
       readmsg(parmbuf, NULL);

       result = (clock_t)(UNLOAD32(parmbuf,0));
       _unlock();
       return result;
    }

    It seems it's also register reading just like the TSCH/TSCL registers. So my question is why the access of these timer register is much slower than the access of TSCH/TSCL registers when multiple clock() calls in a function?

    BR

    Touse

  • Touse,

    I do not see the "register reading" in the source code above. I see "writemsg" and "readmsg" which sound a lot more complex. This may be the cause of the slower operation.

    HOSTclock() sounds like a function that is going to return the time from the PC. That would be extremely slow, not anywhere near 10 times as slow as reading TSCH/TSCL.

    My recommendation is to quit using the clock() function and use the TSCH/TSCL instead.

    Regards,
    RandyP

     

    If you need more help, please reply back. If this answers the question, please click  Verify Answer  , below.

  • I agreed with RandyP.