Last active
April 22, 2016 12:30
-
-
Save tatocaster/d050425a1b4267a69558 to your computer and use it in GitHub Desktop.
check network speed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function checkSpeed(){ | |
| var start_time = Date.now(); | |
| var fileSizeCall = $.ajax({ | |
| type: "HEAD", | |
| url: "//tatocaster.me/20MB.zip", | |
| success: function(msg){ | |
| // 1sec == 1000ms . | |
| var timeSecs = Math.round((Date.now() - start_time)+3)/100; | |
| //1mbps == 1000kbps | |
| var sizeMB = fileSizeCall.getResponseHeader('Content-Length')/1000000; | |
| var result = Math.round(sizeMB/timeSecs); | |
| // alert('Connection Speed is ' + result + ' Mbps'); | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment