Last active
October 9, 2015 07:00
-
-
Save showwin/5e9fe93751c7aa251f5f to your computer and use it in GitHub Desktop.
Speedtesting Tool for Japan
This file contains 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
###### README ###### | |
# Speedtesting Tool for Japan | |
# | |
# How to Use | |
# 1. Install pip | |
# `$ curl -kL https://raw.github.com/pypa/pip/master/contrib/get-pip.py | sudo python` | |
# | |
# 2. Install speedtest-cli (https://github.com/sivel/speedtest-cli) | |
# `$ pip install speedtest-cli` | |
# | |
# 3. Run This Script | |
# `$ ruby speedtest.rb` | |
# | |
# 4. Return Result | |
# `> Download Avg: 48.27 Mbit/s` | |
# `> Upload Avg: 44.79 Mbit/s` | |
###### README ###### | |
REGIONS = %w(Shizuoka Tokyo Misawa Sakai) | |
RIDS = %w(6691 6424 6405 6477) | |
results = {} | |
REGIONS.each_with_index do |region, index| | |
puts "Speedtesting to #{REGIONS[index]} ..." | |
results[region] = `speedtest-cli --server #{RIDS[index]}` | |
end | |
download = 0 | |
upload = 0 | |
results.each do |_, result| | |
result =~ /Download:.+\/s/ | |
down_str = $& | |
down_str =~ /[0-9]+\.[0-9]+/ | |
download += $&.to_f | |
result =~ /Upload:.+\/s/ | |
up_str = $& | |
up_str =~ /[0-9]+\.[0-9]+/ | |
upload += $&.to_f | |
end | |
puts "\n" | |
puts "Date: #{Time.now.strftime('%Y/%m/%d %H:%M:%S')}" | |
puts "Download Avg: #{(download / 4.0).round(2)} Mbit/s" | |
puts "Upload Avg: #{(upload / 4.0).round(2)} Mbit/s" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment