Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Download Speed Meter

Hey people. I was bored and decided to (as always) over code a class for measuring download speeds. It will basically download a file and calculate the size of it the time it took to download and calculate the speed in a nice structure(bps, Kbps, Mbps, Gbps). In the example there is a link given to a file that is exactly 1.000.000 bytes big. I will have to note that this will give you BITS PER SECOND not BYTES PER SECONDS. And also it takes in measurement 1 Mb = 1000 Kb. You need to specify the URL in the New method as a argument. And when you want to measure, you need to call the Measure() method. When it finishes, the Complete() event will be risen. It has event arguments. It will give you the file size, time needed to download and a structure with the speed in 4 different measurements(bps, Kbps, Mbps, Gbps). The Error event is risen whenever there is a error, don't bitch about this, because I like to handle errors like that, and that's how I do it. There is also if you notice another method called SimpleMeasure(), that is basically the whole class in one very tiny method. It is not async, but for anyone that will say that it can be done shorter, I proved him right. Enough talking here is the code(example included): http://pastebin.com/Tj9m4ZzH

UPDATE: There is not a string representation with the appropriate measurement represented as string in the event args as a text string variable.
Thanks for this ma niggs, I'm sure this would become useful soon.
Nice share man. Small modification for auto unit set like if speed is upper than 1024 kbps show 1 mbps this make more useful. When go home i gonna do this and post here or you can do this.
Really useful for autoupdate systems thanks again.
(Jul 25, 2014 04:49 PM)VirinomTR Wrote:  Nice share man. Small modification for auto unit set like if speed is upper than 1024 kbps show 1 mbps this make more useful. When go home i gonna do this and post here or you can do this.
Really useful for autoupdate systems thanks again.

Tnx for the suggestion. I already have that in another project. Let me just implement it here.


Done, Implemented string capability.
Nice... very useful ;) Will look into code to learn new thing ;)
BTC - bc1q3efew3yzfwhdz290dafykaw0a2w56g2j69g2c6
ETH - 0xf1c873217032468990D3313da6509D1b813c4671
USDT - 0xf1c873217032468990D3313da6509D1b813c4671
PP - [email protected]
Nice share. I see that there's a lot of work in the class. Good job.
Decent enough by WHY are you using a loop to update? lol use events and this would be far better.

Thanks for the share
(Jul 26, 2014 05:43 AM)Cairns Wrote:  Decent enough by WHY are you using a loop to update? lol use events and this would be far better.

Thanks for the share

Wrong thread obviously. There is not a single loop here, and it works all with events.
wth is this

Code
Sub Main()
      Do
      Console.Clear()
      Console.Title = "Download Speed Meter"
      Console.ForegroundColor = ConsoleColor.Green
      Console.WriteLine("======Download Speed Meter======")
      Console.ForegroundColor = ConsoleColor.Gray
      DSM.Measure()
      Console.WriteLine("Simple: {0}", DSM.SimpleMeasure())
      Console.ReadLine()
      Loop
    End Sub
(Jul 26, 2014 09:20 AM)Cairns Wrote:  wth is this

Code
Sub Main()
      Do
      Console.Clear()
      Console.Title = "Download Speed Meter"
      Console.ForegroundColor = ConsoleColor.Green
      Console.WriteLine("======Download Speed Meter======")
      Console.ForegroundColor = ConsoleColor.Gray
      DSM.Measure()
      Console.WriteLine("Simple: {0}", DSM.SimpleMeasure())
      Console.ReadLine()
      Loop
    End Sub

Lol, I just had a little bit more fun than I should had with the console colors.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by ChillaeJan 14, 2016 02:25 AM 0 140 Jan 14, 2016 02:25 AM
Last Post: Chillae
[Java] by R҉eece҉Oct 5, 2014 10:20 AM 14 395 Oct 5, 2014 10:20 AM
Last Post: ObscureCoder
[.NET] by iSevereSep 1, 2014 11:34 AM 0 67 Sep 1, 2014 11:34 AM
Last Post: iSevere