Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rubyで作るネット回線の自動速度測定ツール / Automatic network band...

Ryo Nakano
November 30, 2019

Rubyで作るネット回線の自動速度測定ツール / Automatic network bandwidth measurement tool built with Ruby

Ryo Nakano

November 30, 2019
Tweet

Other Decks in Technology

Transcript

  1. TFMG w த໺ཾ ͳ͔ͷΓΐ͏  w !SZPOLO w 3VCZ޷͖ͳωοτϫʔΫΤϯδχΞ w

    גࣜձࣾγφϓε w ೥૑ۀ w ࣛࣇౡͷΠϯλʔωοταʔϏε ϓϩόΠμ *41
  2. Πϯλʔωοτ 1$ "1 ϧʔλ ϧʔλ ϧʔλ ϧʔλ ϧʔλ ϧʔλ εΠον

    αʔό αʔό αʔό *41 $41 2ϘτϧωοΫͷՄೳੑ͸Ͳ͜
  3. ؀ڥ Πϯλʔωοτ γφϓε ଞࣾ ଎౓ଌఆ Ϛγϯ TQFFEUFTUOFUͷ Ͳ͔ͬͷαʔό ճઢ" ճઢ#

    ճઢ$ TQFFEUFTUOFUͷ Ͳ͔ͬͷαʔό TQFFEUFTUOFUͷ Ͳ͔ͬͷαʔό "NB[PO $MPVE8BUDI
  4. "NB[PO $MPVE8BUDI ؀ڥ Πϯλʔωοτ γφϓε ଞࣾ ଎౓ଌఆ Ϛγϯ TQFFEUFTUOFUͷ Ͳ͔ͬͷαʔό

    ճઢ" ճઢ# ճઢ$ TQFFEUFTUOFUͷ Ͳ͔ͬͷαʔό TQFFEUFTUOFUͷ Ͳ͔ͬͷαʔό ճઢ"Λ࢖ͬͯγφϓεܦ༝Ͱɺࣗಈબ୒͞Εͨ TQFFEUFTUOFUͷͲ͔ͬͷαʔόͰ଎౓ଌఆ
  5. "NB[PO $MPVE8BUDI ؀ڥ Πϯλʔωοτ γφϓε ଞࣾ ଎౓ଌఆ Ϛγϯ TQFFEUFTUOFUͷ Ͳ͔ͬͷαʔό

    ճઢ" ճઢ# ճઢ$ TQFFEUFTUOFUͷ Ͳ͔ͬͷαʔό TQFFEUFTUOFUͷ Ͳ͔ͬͷαʔό ճઢ#Λ࢖ͬͯγφϓεܦ༝Ͱɺࣗಈબ୒͞Εͨ TQFFEUFTUOFUͷͲ͔ͬͷαʔόͰ଎౓ଌఆ
  6. ؀ڥ Πϯλʔωοτ γφϓε ଞࣾ ଎౓ଌఆ Ϛγϯ TQFFEUFTUOFUͷ Ͳ͔ͬͷαʔό ճઢ" ճઢ#

    ճઢ$ TQFFEUFTUOFUͷ Ͳ͔ͬͷαʔό TQFFEUFTUOFUͷ Ͳ͔ͬͷαʔό ճઢ$Λ࢖ͬͯଞࣾܦ༝Ͱɺࣗಈબ୒͞Εͨ TQFFEUFTUOFUͷͲ͔ͬͷαʔόͰ଎౓ଌఆ "NB[PO $MPVE8BUDI
  7. ؀ڥ Πϯλʔωοτ γφϓε ଞࣾ ଎౓ଌఆ Ϛγϯ TQFFEUFTUOFUͷ Ͳ͔ͬͷαʔό ճઢ" ճઢ#

    ճઢ$ TQFFEUFTUOFUͷ Ͳ͔ͬͷαʔό TQFFEUFTUOFUͷ Ͳ͔ͬͷαʔό ଎౓ଌఆͷ݁ՌΛ$MPVE8BUDIʹૹ৴ "NB[PO $MPVE8BUDI
  8. Ͳ͏΍ͬͯ௨৴଎౓Λܭࢉ͢Δ start_time = Time.now size = do_something elapsed_time = Time.now

    - start_time bits_per_seconds = size / elapsed_time ௨৴଎౓ CQT  సૹྔ CJUT సૹ࣌ؒ TFDPOET
  9. Ͳ͏΍ͬͯ௨৴଎౓Λܭࢉ͢Δ start_time = Time.now size = do_something elapsed_time = Time.now

    - start_time bits_per_seconds = size / elapsed_time ௨৴଎౓ CQT  సૹྔ CJUT సૹ࣌ؒ TFDPOET ͜͜ͷॲཧ͕࣌ؒ ୹͍͜ͱ͕େࣄ
  10. Ͳ͏΍ͬͯ௨৴଎౓Λܭࢉ͢Δ start_time = Time.now size = do_something elapsed_time = Time.now

    - start_time bits_per_seconds = size / elapsed_time ௨৴଎౓ CQT  సૹྔ CJUT సૹ࣌ؒ TFDPOET ͜͜ͷॲཧ͕࣌ؒ ୹͍͜ͱ͕େࣄ Ͱ͸ɺͲͷ)551 ϥΠϒϥϦΛ͔ͭ͏ ΂͖
  11. ϕϯνϚʔΫ؀ڥ w .BD#PPL 3FUJOB JODI   w NBD04$BUBMJOB 

     w 3VCZQSFWJFX w ର৅ͷ)551ϥΠϒϥϦ w OFUIUUQ PQFOVSJ QFSTJTUFOU@IUUQ FYDPO DVSC  UZQIPFVT IUUQBSUZ w ൺֱ಺༰ w .#ͷϑΝΠϧͷ ճμ΢ϯϩʔυʹ͔͔Δ࣌ؒ
  12. ϕϯνϚʔΫ݁Ռ user system total real net/http 14.414228 28.327082 42.741310 (

    77.200037) open-uri 15.608099 42.493993 58.102092 (115.153421) persistent_http 16.415132 19.942348 36.357480 (204.295474) excon 25.617961 35.878296 61.496257 ( 92.624589) curb 7.818012 10.445636 18.263648 ( 31.450269) typhoeus 16.514283 13.611175 30.125458 ( 43.214387) httparty 16.402169 27.036087 43.438256 ( 73.769290)
  13. ϕϯνϚʔΫ݁Ռ ࣌ؒ ඵ      OFUIUUQ PQFOVSJ

    QFSTJTUFOU@IUUQ FYDPO DVSC UZQIPFVT IUUQBSUZ               VTFS TZTUFN
  14. ϕϯνϚʔΫ݁Ռ ࣌ؒ ඵ      OFUIUUQ PQFOVSJ

    QFSTJTUFOU@IUUQ FYDPO DVSC UZQIPFVT IUUQBSUZ               VTFS TZTUFN ࠾༻
  15. ॲཧ֓ཁ module SpeedtestNet def self.run config = SpeedtestNet::Config.fetch server =

    SpeedtestNet::Server.best_server download_results = SpeedtestNet::Download.measure(server) upload_results = SpeedtestNet::Upload.measure(server) SpeedtestNet::Config.clear_cache SpeedtestNet::Result.new(config.client, server, download_results, upload_results) end end
  16. ॲཧ֓ཁ module SpeedtestNet def self.run config = SpeedtestNet::Config.fetch server =

    SpeedtestNet::Server.best_server download_results = SpeedtestNet::Download.measure(server) upload_results = SpeedtestNet::Upload.measure(server) SpeedtestNet::Config.clear_cache SpeedtestNet::Result.new(config.client, server, download_results, upload_results) end end TQFFEUFTUOFUΑΓɺࣗ ਎ͷύϒϦοΫ*1ɺͦͷ *1ͷҢ౓ɾܦ౓Λऔಘ
  17. ॲཧ֓ཁ module SpeedtestNet def self.run config = SpeedtestNet::Config.fetch server =

    SpeedtestNet::Server.best_server download_results = SpeedtestNet::Download.measure(server) upload_results = SpeedtestNet::Upload.measure(server) SpeedtestNet::Config.clear_cache SpeedtestNet::Result.new(config.client, server, download_results, upload_results) end end TQFFEUFTUOFUΑΓɺଌఆ αʔόҰཡΛड৴ͯ͠ɺۙ͘ ͯ஗Ԇͷগͳ͍αʔόΛબఆ
  18. ॲཧ֓ཁ module SpeedtestNet def self.run config = SpeedtestNet::Config.fetch server =

    SpeedtestNet::Server.best_server download_results = SpeedtestNet::Download.measure(server) upload_results = SpeedtestNet::Upload.measure(server) SpeedtestNet::Config.clear_cache SpeedtestNet::Result.new(config.client, server, download_results, upload_results) end end μ΢ϯϩʔυ଎౓ ͷଌఆ
  19. ॲཧ֓ཁ module SpeedtestNet def self.run config = SpeedtestNet::Config.fetch server =

    SpeedtestNet::Server.best_server download_results = SpeedtestNet::Download.measure(server) upload_results = SpeedtestNet::Upload.measure(server) SpeedtestNet::Config.clear_cache SpeedtestNet::Result.new(config.client, server, download_results, upload_results) end end Ξοϓϩʔυ଎౓ ͷଌఆ
  20. ॲཧ֓ཁ module SpeedtestNet def self.run config = SpeedtestNet::Config.fetch server =

    SpeedtestNet::Server.best_server download_results = SpeedtestNet::Download.measure(server) upload_results = SpeedtestNet::Upload.measure(server) SpeedtestNet::Config.clear_cache SpeedtestNet::Result.new(config.client, server, download_results, upload_results) end end ଌఆ݁ՌΛฦ͢
  21. ࢖͍ํ irb(main):001:0> require 'speedtest_net' irb(main):002:0> result = SpeedtestNet.run irb(main):003:0> result.download

    => 511615528.0 irb(main):004:0> result.pretty_download => "511.62 Mbps” irb(main):005:0> result.upload => 647852285.33333334 irb(main):006:0> result.pretty_upload => "647.85 Mbps"