gerz0ckerz
Goto Top

Wie berechene ich die Download Geschwindigkeit?

Ich möchte die Geschwindigkeit eines Downloads berechnen der per Webclient.Downloadfileasync gestartet wird in KB/S und MB/S berechnen, wie stelle ich das an?

Content-Key: 310625

Url: https://administrator.de/contentid/310625

Printed on: April 25, 2024 at 00:04 o'clock

Mitglied: 129813
Solution 129813 Jul 23, 2016 updated at 08:32:50 (UTC)
Goto Top
speed = data / interval

Did you miss the first math lessons in school face-smile?

VB.Net example Form
Imports System.Net

Public Class Form1
    WithEvents client As WebClient
    Dim currentBytes As Long = 0
    Dim lastBytes As Long = 0
    WithEvents tm As Timer

    Private Sub btnDownload_Click(sender As Object, e As EventArgs) Handles btnDownload.Click
        client = New WebClient
        tm = New Timer()
        With tm
            .Interval = 500
            .Start()
        End With
        client.DownloadFileAsync(New Uri("http://domain/download.iso"), Environ("Temp") & "\test.iso")  
    End Sub

    Private Sub client_DownloadProgressChanged(sender As Object, e As DownloadProgressChangedEventArgs) Handles client.DownloadProgressChanged
        pBar.Value = e.ProgressPercentage
        currentBytes = e.BytesReceived
    End Sub

    Private Sub btnStopDownload_Click(sender As Object, e As EventArgs) Handles btnStopDownload.Click
        client.CancelAsync()
        tm.Stop()
    End Sub

    Private Sub tm_Tick(sender As Object, e As EventArgs) Handles tm.Tick
        Dim speed As String
        Dim lngDataPerInterval As Long = currentBytes - lastBytes
        If lngDataPerInterval < (1024 * 1024) Then
            speed = Math.Round((lngDataPerInterval / 1024) / (tm.Interval / 1000), 0) & " KB/s"  
        Else
            speed = Math.Round((lngDataPerInterval / (1024 * 1024)) / (tm.Interval / 1000), 2) & " MB/s"  
        End If
        lblStatus.Text = speed
        lastBytes = currentBytes
    End Sub
End Class
Regards
Member: aqui
aqui Jul 23, 2016 at 08:32:30 (UTC)
Goto Top
Did you miss the first math lessons in school
Indeed ! Missed completely what we call in the German Grundschule "das kleine Einmaleins" !
Mitglied: 129813
129813 Jul 23, 2016 updated at 08:38:46 (UTC)
Goto Top
Zitat von @aqui:
Did you miss the first math lessons in school
Indeed ! Missed completely what we call in the German Grundschule "das kleine Einmaleins" !
I suppose, teached by Super Mario face-big-smile
Member: aqui
aqui Jul 23, 2016 updated at 14:17:31 (UTC)
Goto Top
two fours love each other and get a baby 4....GREAT !!! face-big-smile

On top a stupid doublepost:
Webclient Download Größe in KB, MB etc. umrechnen