Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8643977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:10:58+00:00 2026-06-12T12:10:58+00:00

I am running a C program using GCC and a proprietary DSP cross-compiler to

  • 0

I am running a C program using GCC and a proprietary DSP cross-compiler to simulate some functioality. I am using the following code to measure the execution time of particular part of my program:

clock_t start,end;
printf("DECODING DATA:\n");
start=clock();
conv3_dec(encoded, decoded,3*length,0);
end=clock();
duration = (double)(end - start) / CLOCKS_PER_SEC;
printf("DECODING TIME = %f\n",duration);

where conv3_dec() is a function defined in my program and I want to find the run-time of this function.

Now the thing is when my program runs, the conv3_dec() functions runs for almost 2 hours but the output from the printf("DECODING TIME = %f\n",duration) says that the execution of the function finished in just half a second (DECODING TIME = 0.455443) . This is very confusing for me.

I have used the clock_t technique to measure the runtimes of programs previously but the difference has never been so huge. Is this being caused by the cross-compiler. Just as a side note, the simulator simulates a DSP processor running at just 500MHz, so is the difference in the clock speeds of the DSP processor and my CPU causing the error is measuring the CLOCKS_PER_SEC.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:10:59+00:00Added an answer on June 12, 2026 at 12:10 pm

    For durations like two hours, I wouldn’t be too concerned about clock(), it’s far more useful for measuring sub-second durations.

    Just use time() if you want the actual elapsed time, something like (dummy stuff supplied for what was missing):

    #include <stdio.h>
    #include <time.h>
    
    // Dummy stuff starts here
    #include <unistd.h>
    #define encoded 0
    #define decoded 0
    #define length 0
    static void conv3_dec (int a, int b, int c, int d) {
        sleep (20);
    }
    // Dummy stuff ends here
    
    int main (void) {
        time_t start, end, duration;
        puts ("DECODING DATA:");
        start = time (0);
        conv3_dec (encoded, decoded, 3 * length, 0);
        end = time (0);
        duration = end - start;
        printf ("DECODING TIME = %d\n", duration);
        return 0;
    }
    

    which generates:

    DECODING DATA:
    DECODING TIME = 20
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have made a program in C using the gcc compiler. Right now it
I just built a cross compiler using crosstools mips-unknown-linux-gnu-gcc and I compiled a hello
I am using cygwin gcc version 4.5.3 to compile the following code. /* recursion.c
While running following code, my program crashes unexpectedly! #include<stdio.h> #include<string.h> int main(){ char *str
I would like to cross-compile a simple program for ARM architecture using the arm-linux-gcc
The following simple program segfaults on my mac (Lion) running gcc 4.2.1: #include <iostream>
When running a java program using the java command you can specify the verbose
My main program running 8 tasks using Task.Factory.StartNew Each task will request XML format
I have a program in C++, using the standard socket API, running on Ubuntu
I have a program running under WPF and MVVM. I have some daily worked

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.