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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:34:25+00:00 2026-05-19T23:34:25+00:00

I need to time or benchmark a number crunching application written in C/C++. The

  • 0

I need to “time” or benchmark a number crunching application written in C/C++. The problem is that the machine where I run the program is usually full of people doing similar things, so the CPUs are always at full load.

I thought about using functions from time.h liket “get time of the day” (don’t remember the exact syntax, sorry) and similars, but I am afraid they would not be good for this case, am I right?

And the program “time” from bash, gave me some errors long time ago.

Also the problem is, that sometimes I need to get timings in the range of 0.5 secs and so on.

Anybody has a hint?

P.S.: compiler is gcc and in some cases nvcc (NVIDIA)
P.S.2: in my benchmarks I just want to measure the execution time between two parts of the main function

  • 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-19T23:34:25+00:00Added an answer on May 19, 2026 at 11:34 pm

    From your other recent questions, you seem to be using MPI for parallelisation. Assuming this question is within the same context, then the simplest way to time your application would be to use MPI_Wtime().

    From the man page:

    This subroutine returns the current
    value of time as a double precision
    floating point number of seconds. This
    value represents elapsed time since
    some point in the past. This time in
    the past will not change during the
    life of the task. You are responsible
    for converting the number of seconds
    into other units if you prefer.

    Example usage:

    #include "mpi.h"
    
    int main(int argc, char **argv)
    {
        int rc, taskid;
        double t_start, t_end;
    
        MPI_Init(&argc,&argv);
        MPI_Comm_rank(MPI_COMM_WORLD,&taskid); 
    
        t_start = MPI_Wtime();
    
        /* .... your computation kernel .... */
    
        t_end = MPI_Wtime();
    
        /* make sure all processes have completed */
        MPI_Barrier(MPI_COMM_WORLD);
    
        if (taskid == 0) {
            printf("Elapsed time: %1.2f seconds\n", t_start - t_end);
        }
    
        MPI_Finalize();
        return 0;
    } 
    

    The advantage of this is that we let the underlying MPI library handle platform specific ways of handling time, although you might want to use MPI_Wtick() to determine the resolution of the timer used on each platform.

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

Sidebar

Related Questions

From time to time I need to run a full build of the entire
I am developing a android application where I need time stamp should be saved
I need a time delay between each cURL call so that one process do
Need of time server services I am trying to build a web application in
I need to time a CUDA kernel execution. The Best Practices Guide says that
ive table olduser and table user I need every time to run sql statement
I have a one-time need to create a file from an iOS mutable array.
I am implementing a system where I need real-time updates. I have been looking
Every time I need to work with date and/or timstamps in Java I always
Often time I need to add a control to a dialog after the dialog

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.