Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

sorting time issue

Hi,

I want to calculate the time taken to sort the files alphabetically. I am using timestamp driver. In the output gives me the sorted file names but the the time taken to sort it is always zero.

I am using DE2 board. Following is my code


#include "sys/alt_timestamp.h"# include "alt_types.h"# include <stdio.h># include <string.h>
 
//Sort() definition
int main()
{
int i; /* loop variable */
alt_u32 time1;
alt_u32 time2;
 
alt_timestamp_start();
time1 = alt_timestamp();
 
//sort();
time2 = alt_timestamp();
 
printf("Time taken to print = %u ticks\n", (unsigned int)time2-time1);
printf("Number of ticks per second = %u\n",(unsigned int)alt_timestamp_freq());
 
}

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hello,

    Here are some points that I would check first :

    - Are you sure you have a timestamp component in your system ?

    - Check the value returned by alt_timestamps_start() (0 if success)

    - Which value return alt_timestamps_frequency() ?

    - the // before your sort function is just here, it is not really in your code (just to be sure) ?

    Jérôme
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks for the reply.

    The problem was I have sys_clk_timer enabled in my system. I turned it off and now it is working fine. :)