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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:32:37+00:00 2026-06-08T18:32:37+00:00

How could I estimate the instantaneous throughput ? For example, in a way similar

  • 0

How could I estimate the instantaneous throughput ? For example, in a way similar to what the browser does when downloading a file. It’s not just a mean throughput, but rather the an instantaneous estimation, maybe with a ‘moving average’. I’m looking for the algorithm, but you can specify it in c++. Ideally, it would not involve a thread (i.e., being continuously refreshed, say every second) but rather be only evaluated when the value is asked.

  • 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-08T18:32:38+00:00Added an answer on June 8, 2026 at 6:32 pm

    You can use an exponential moving average, as explained here, but I’ll repeat the formula:

    accumulator = (alpha * new_value) + (1.0 - alpha) * accumulator
    

    To achieve an estimation, suppose you intend to query the computation every second, but you want an average over the last minute. Then, here would be one way to get that estimate:

    struct AvgBps {
        double rate_;            // The average rate
        double last_;            // Accumulates bytes added until average is computed
        time_t prev_;            // Time of previous update
        AvgBps () : rate_(0), last_(0), prev_(time(0)) {}
        void add (unsigned bytes) {
            time_t now = time(0);
            if (now - prev_ < 60) {       // The update is within the last minute
                last_ += bytes;           // Accumulate bytes into last
                if (now > prev_) {        // More than a second elapsed from previous
                    // exponential moving average
                    // the more time that has elapsed between updates, the more
                    // weight is assigned for the accumulated bytes
                    double alpha = (now - prev_)/60.0;
                    rate_ = (1 -alpha) * last_ + alpha * rate_;
                    last_ = 0;            // Reset last_ (it has been averaged in)
                    prev_ = now;          // Update prev_ to current time
                }
            } else {                      // The update is longer than a minute ago
                rate_ = bytes;            // Current update is average rate
                last_ = 0;                // Reset last_
                prev_ = now;              // Update prev_
            }
        }
        double rate () {
            add(0);                       // Compute rate by doing an update of 0 bytes
            return rate_;                 // Return computed rate
        }
    };
    

    You should actually use a monotonic clock instead of time.

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

Sidebar

Related Questions

Could someone know where is saved path to external XML-File that contain configuration for
I'm sure there is a better way I could be doing this. I have
I am looking for a way to estimate which developer contributed the most code
I'm looking for a good way to estimate the power of a signal (regularly
This behavior is strange because I could not get the segfault if the shared
I think this question has not to do with programming in general, but nevertheless
I'm not talking about the kind you get in college, but rather implementing progress
Could anyone guide me in created a simple app in JS? What the app
Could someone please tell me why this <%= destroy_password_url @user.password_reset_token %> generates http://localhost:3000/api/destroy_password.4G5EoRVYMUAtiIKqOerKsw routes.rb
Could this be done with javascript/jQuery : <div class=number>99,123,123</div> <div class=number>123,123,123</div> <div class=number>1,123,123,123</div> <div

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.