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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:08:43+00:00 2026-06-09T15:08:43+00:00

I need to calculate the approximate amount of time an algorithm will take without

  • 0

I need to calculate the approximate amount of time an algorithm will take without actually running the code.

I cannot actually let the full algorithm run since it takes days or weeks to complete depending on hardware. The algorithm in logarithmic in nature. Following is an estimation of the algorithm. There is no logic included here of course.

We start with 2 raised to the power of [n] where [n] is large number.

int baseTwo = 2;
double log = 0D;
BigInteger number = 0;
double exponent = 5000000; // 5,000,000.

while (exponent > 0)
{
    number = BigInteger.Pow(baseTwo, (int) exponent); // [baseTwo]=2 raised to the power [exponent].
    number = this.ProcessNumber(number, baseTwo); // Returned number will be slightly smaller than what went in.
    exponent = BigInteger.Log(number, baseTwo); // The Base 2 Log to calculate the slightly decreased exponent (if exponent was 38762, then the result would be 38761.4234 for example).
}

private BigInteger ProcessNumber(BigInteger number)
{
    double rand = 0;
    BigInteger result = 0;

    rand = Random.Next(51, 100) / 100D; // Anywhere between 51% to 99%.
    result = number * rand; // [result] will always be less than [number] but more than half of [number].

    return (result);
}

Since the exponents are iterating towards zero, the time per iteration naturally decreases from one iteration to the next.

  • Given the execution time of the first and last iterations on my machine, is there a way to calculate the total time?
  • If not, we could take discreet ranges for [exponent] say 5,000,000, 4,500,000, 4,000,000, etc. and calculate from there?
  • 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-09T15:08:44+00:00Added an answer on June 9, 2026 at 3:08 pm

    Just the first and last iterations won’t provide you with sufficient information, even if you know the limiting big-O efficiency of the algorithm, because there is no guarantee that the time per iteration will scale exactly to the limiting efficiency. For example, if your function was O(n^2) in the limit for large n (I know it isn’t in this case – but this is just for the sake of illustation), but the actual time per step of real code was something like 1*log(n) + 10^-6*n + 10^-24*n^2, you might not see n^2 behaviour over the range of n you choose to look at. So you would have two points at the first and last iteration, but no way of knowing how to draw the line between them.

    You could sample the data at regular intervals as you suggest, and then export it for fitting and/or numerical integration. But assumiong you only need to know the approximate total time (+/-10% perhaps) it should be suficient to do something along the lines of…
    Pseudo-code:

    totaltime = 0;
    for i := 0 to 5 do
    begin
      starttime = now;
      for j := 0 to 10 do
        run algorithm(i*10^6+j)
      endtime = now;
      totaltime := totaltime + 10^5*(endtime - starttime);
      writeln('10 iterations near ', i*10^6, ' takes ', endtime - starttime, ' seconds');
    end;
    writeln('approximate time for complete algorithm to run is', totaltime);
    

    .. and get an answer in less time than it has taken me to write this.

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

Sidebar

Related Questions

Need to calculate a date before a given time (let it be 10 years)
I need to calculate the time till Christmas in milliseconds. I'm using joda time
I need to calculate the number of FULL month in SQL, i.e. 2009-04-16 to
I need to calculate an approximate image size in inches assuming 300dpi. I have
I need to calculate how much time was spent on a bug. I saw
I need calculate an URL and redirect to it. I have the following code:
I need to calculate the Italian fiscal code (tax code) in C#. I've found
I need to calculate the total of an invoice. This invoice is created with
I need to calculate (in R) the number of positive and negative runs in
I need to calculate the net total of a column-- sounds simple. The problem

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.