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

  • Home
  • SEARCH
  • 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 7936481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:13:46+00:00 2026-06-03T22:13:46+00:00

In my download manager application, I’m using the code below to calculate the current

  • 0

In my download manager application, I’m using the code below to calculate the current transfer rate:

        TimeSpan interval = DateTime.Now - lastUpdateTime;

        downloadSpeed = (int)Math.Floor((double)(DownloadedSize + cachedSize - lastUpdateDownloadedSize) / interval.TotalSeconds);

        lastUpdateDownloadedSize = DownloadedSize + cachedSize;
        lastUpdateTime = DateTime.Now;

This mostly works the way I want (I’m updating the speed every 4 seconds or so), but there are always some crazy spikes in the download rate as it fluctuates. My average download speed is around 600 kB/s, and sometimes it shows 10.25 MB/s or even negative values like -2093848 B/s. How could this be?

What is the best way to calculate real-time download rate? I’m not interested in the average rate (DownloadedSize / TimeElapsed.TotalSeconds), because it doesn’t give realistic results.

  • 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-03T22:13:47+00:00Added an answer on June 3, 2026 at 10:13 pm

    Given that “real-time” is unachievable, you should try to simulate it, by making the interval as small and precise as possible, and calculating the average over the interval, checking for sanity in the code. For instance:

    DateTime now = DateTime.Now;
    TimeSpan interval = now - lastUpdateTime;
    timeDiff = interval.TotalSeconds;
    sizeDiff = DownloadedSize + cachedSize - lastUpdateDownloadedSize;
    speed = (int)Math.Floor((double)(sizeDiff) / timeDiff);
    lastUpdateDownloadedSize = DownloadedSize + cachedSize;
    lastUpdateTime = now;
    

    One difference with your code:

    1. Only calculate Now once, use it twice.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm planning on writing a custom download manager as part of an application. To
I want to implement a download manager in iPhone. Now it appears that it
im create a windows application C# like a download Manager when run this application
I have a rather complex application at https://github.com/BigBadOwl/iStreamer-Download-Manager which uses Rtmpdump and Ffmpeg libraries
I'm looking for a good web based download manager open source application. Mainly a
I'm thinking of creating an application that can use Firefox as a download manager.
I've got the below code working on Weblogic Application Server 10.3.2. The long running
I have a download manager of sorts that uses WebClient.DownloadFileAsync. Webclient doesn't seem to
I'm building a download manager in python for fun, and sometimes the connection to
If Safari/Firefox have already downloaded files then they keep a download manager window open.

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.