How long will that download take?

I’m currently downloading the March CTP of Visual Studio Orcas. There’s two versions this month, a Virtual PC image and for the first time a full install. Combined this all totals 11.9GB and 20 files to download!

So how long will it take to download on my 4Mbs Internet Connection?

1> New-TimeSpan -seconds $(11.9gb / (4mb / 8))

Days : 0
Hours : 6
Minutes : 46
Seconds : 11
Milliseconds : 0
Ticks : 243710000000
TotalDays : 0.282071759259259
TotalHours : 6.76972222222222
TotalMinutes : 406.183333333333
TotalSeconds : 24371
TotalMilliseconds : 24371000

Of cause, that’s the theoretical maximum of my line, in reality I tend to get about 480KBs:

2> New-TimeSpan -seconds $(11.9gb / (480kb))

Days : 0
Hours : 7
Minutes : 13
Seconds : 16
Milliseconds : 0
Ticks : 259960000000
TotalDays : 0.30087962962963
TotalHours : 7.22111111111111
TotalMinutes : 433.266666666667
TotalSeconds : 25996
TotalMilliseconds : 25996000

Not bad, it’ll e done by breakfast J

I often compute this on a calculator, but PowerShell offers us a better alternative, but typing it into the command line every time will get old very fast. So I’ve just knocked together a little script to do this for me.

Usage: Calc-DownloadTime.ps1 <downloadSize> [connectionSpeed]

Both parameters are int64’s and if connectionSpeed is not supplied, it will try to use a global variable named $networkSpeed. Should the $networkSpeed global variable not exist, the script will throw an exception.

3> .\Calc-DownloadTime.ps1 11.9gb 480kb
Your download will take 07:13:16 to complete

4> .\Calc-DownloadTime.ps1 11.9gb
Usage: calc-downloadTime.ps1 <downloadSize> [connectionSpeed]
If connectionSpeed is not supplied, global variable $networkSpeed will be used.
Please specify a connectionSpeed or set $networkSpeed variable to use as default
At D:\PsScripts\Calc-DownloadTime.ps1:13 char:7
+ throw <<<< “Please specify a connectionSpeed or set `$networkSpeed variable to use as default”;


5> $networkSpeed = 480kb

6> .\Calc-DownloadTime.ps1 11.9gb
Your download will take 07:13:16 to complete

Because I do this a lot and my connection speed is generally static, I’ve added this variable to my profile so it’s there every time I load PowerShell. I’ve seen some people connect that PowerShell profiles should be a light as possible, so if you prefer you can customise the script to default to your connection speed.

1> .\Calc-DownloadTime.ps1 11.9gb
Your download will take 07:13:16 to complete

I can still override this default though should I need to.

2> .\Calc-DownloadTime.ps1 11.9gb $(100mb/8) # My Local LAN
Your download will take 00:16:15 to complete

3> .\Calc-DownloadTime.ps1 11.9gb $(54mb/8) # My WiFi connection
Your download will take 00:30:05 to complete

4> .\Calc-DownloadTime.ps1 11.9gb $(33kb/8) # My phone (GPRS)
Your download will take 35.00:16:23 to complete

Ouch! I better not do this over GPRS!

Download the script here: Calc-DownloadTime.ps1

One Response to “How long will that download take?”

  1. OK, so it’s official, I WANT POWERSHELL FOR WINDOWS MOBILE ;)

Leave a Reply