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 8461891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:00:26+00:00 2026-06-10T14:00:26+00:00

This is my c++ code. double start_time = time(NULL); double start_clock = clock(); #pragma

  • 0

This is my c++ code.

double start_time = time(NULL);
double start_clock = clock();

#pragma omp parallel for private(i) 
for(i=0;i<max_i;i++)
      PROCESS(i);

double end_time = time(NULL);
double end_clock = clock();

printf("%lf second(s)\n", end_time-start_time);
printf("%lf second(s)\n", (end_clock-start_clock)/CLOCKS_PER_SEC);

and this is the output.

took 2.000000 second(s)
took 11.410000 second(s)

Does anyone know why these are not consistent? Is there any other way of measuring this? BTW, 2 seconds seems more reasonable based on the time I’m seeing here.

  • 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-10T14:00:28+00:00Added an answer on June 10, 2026 at 2:00 pm

    The clock() function returns the amount of CPU time used by your process since it started, not the absolute time according to a real-time clock.

    In another comment you said that CODE_BLOCK is a parallel loop – which means in your case, it used the equivalent of 11.41 seconds of CPU time in 2 seconds of real (“wall clock”) time. Evidently you’re using the power of about 6 CPUs in parallel.

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

Sidebar

Related Questions

Any idea why this code: extern C __declspec(dllexport) void Transform(double x[], double y[], int
Consider this code: int main() { int e; prn(e); return 0; } void prn(double
I found this line of code in some code I'm analyzing: Mintau = (double*)
I have this (working) CPU code: #define NF 3 int ND; typedef double (*POT)(double
In code, if I write a code line like this: GClass<Double> x = new
I wrote this code: #include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys/types.h> #include <sys/shm.h>
This is my code: // Start performance test clock assert((start=clock())!=-1); // Some reading and
I use this code for measuring computing time of my C program: clock_t start
Consider this code: #include <stdlib.h> #include <stdarg.h> #include <GLUT/GLUT.h> #include <OpenGL/OpenGL.h> double width=600; double
This code below allows me to find the word error in all my files

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.