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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:46:50+00:00 2026-06-18T23:46:50+00:00

What I mean, to measure performance in some algorithm I need to do it

  • 0

What I mean, to measure performance in some algorithm I need to do it in terms of some unit. So, basically if I ignore declarations and definitions of objects and consider only operations , how would you estimate the time each operation consums in run time?.

  • 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-18T23:46:51+00:00Added an answer on June 18, 2026 at 11:46 pm

    In c++11 you have the std::chrono library (see std::chrono). Otherwise, you can use boost::chrono (see boost::chrono). Those 2 are very basic time measurement libraries you can start with.

    EDIT: In c++0x you have the clock() function – but as noted in the comment section – it is not a very accurate measurement. Plus, most platforms also supply some sort of API for chrono-related operations.

    How to measure performance depends on the context. First, you’ll want to compare performance on a large enough and diverse enough sample data. Large enough means that it is at least measurable in seconds. Diverse enough means that it covers repetition of all run scenarios either uniformly or perhaps separately (you should at lease know what cut the sample data represents).

    For simple enough cases, the first thing you’ll want to do is partition your algorithm into as many as needed segments, let’s call them A_1,...,A_N (or perhaps A_1...A_N are different solutions to the same problem, the concept still holds). What you’ll want to do is measure the amount of time spent on each partition over the same sample data. In pseudo-code:

    times <- (0,...,0) //vector of size N
    for each input in sample data:
        start = now()
        //Run A_1 on input
        end = now()
        times[1] <- times[1] + (end-start)
        ...
        ...
        ...
        start = now()
        //Run A_N on input
        end = now()
        times[N] <- times[N] + (end-start)
    

    At the end of this run you are left with a times vector which shows you how much time you’ve spent in each element. That is the most basic approach. But the key element to profiling is: there are many ways to dissect a frog. You could also look at how much time you are spending on a specific operation which could be called from many partitions of the algorithm. You could choose to look at the number of load/store operations, cache performance etc. The variations are numerous and great reward can often come from unexpected sources (at least to the unwary observer).

    For more advanced profiling, you can use a 3rd party profiling framework (some IDEs come with built-in profiling capabilities).

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

Sidebar

Related Questions

Are there any tools to measure performance (similar to FireBug > Net tab (FireBugLite
I need to measure function execution time in nanoseconds. Now I want to understand
I have a dataset with numbers indicating daily difference in some measure. https://dl.dropbox.com/u/22681355/diff.csv I
Some web pages that I process in Jsoup are heavy. By heavy I mean
I'm currently working on algorithm for denoising images. I need to compare my algorithm
Is it possible to measure distance to object with phone camera? I mean, in
So basically, besides possible performance effects, does inlining functions have any considerable effect on
I want to make some performance measures (mainly runtime) for my Java code, a
I've been asked to measure the performance of a fortran program that solves differential
How to measure bounds of space in android? I mean, the following: Rect bounds

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.