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

  • SEARCH
  • Home
  • 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 7614295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:22:04+00:00 2026-05-31T02:22:04+00:00

I use time command on linux to measure how long my program took, and

  • 0

I use time command on linux to measure how long my program took, and in my code I have put timers to calculate time

time took calculated by program: 71.320 sec

real    1m27.268s
user    1m7.607s
sys 0m3.785s

I don’t know why my program took real time more than calculated, how to find the reason and resolve it?

======================================================

here is how I calculate time in my code;

clock_t cl;
cl = clock();

do_some_work();

cl = clock() - cl;
float seconds = 1.0 * cl / CLOCKS_PER_SEC;
printf("time took: %.3f sec\n", seconds);
  • 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-05-31T02:22:05+00:00Added an answer on May 31, 2026 at 2:22 am

    There always is overhead for starting up the process, starting the runtime, closing the program and time itself probably also has overhead.

    On top of that, in a multi-process operating system your process can be “switched-out”, meaning that other processes run while yours in put on hold. This can mess with timings too.

    Let me explain the output of time:

    • real means the actual clock time, including all overhead.
    • user is time spent in the actual program.
    • sys is time spent by the kernel system (the switching out I talked about earlier, for example)

    Note that user + sys is very close to your time: 1m7.607s + 0m3.785s == 71.392s.

    Finally, how did you calculate the time? Without that information it’s hard to tell exactly what the problem (if any) is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On linux we can use time command. Or from C++: #include <sys/time.h> #include <sys/resource.h>
first time use JTree. Just wondering is it possible to have more than one
Any time I use the recipe at http://code.activestate.com/recipes/134892/ I can't seem to get it
Usually I use shell command time . My purpose is to test if data
i have develop a eblast application The program is use to send a email
We have two Linux servers, ServerA and ServerB. The system time on ServerA seems
I'm trying to compile this simple program to start learning how to use timers:
I'd like to use date time format string (possibly UTC) which is understandable and
My Rails application makes use of Time.zone so that each user can set their
What format do I use for Date/Time when writing to an XML file using

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.