Class: SpeedtestNet::Upload

Inherits:
Object
  • Object
show all
Defined in:
lib/speedtest_net/upload.rb

Constant Summary collapse

SIZE =
[250_000, 500_000, 1_000_000, 2_000_000, 4_000_000, 8_000_000,
12_000_000, 17_000_000, 24_000_000, 32_000_000].freeze

Class Method Summary collapse

Class Method Details

.measure(server, timeout: HTTP_TIMEOUT) ⇒ Object

rubocop:disable Metrics/MethodLength



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/speedtest_net/upload.rb', line 15

def measure(server, timeout: HTTP_TIMEOUT) # rubocop:disable Metrics/MethodLength
  config = Config.fetch
  concurrent_number = config.upload[:threadsperurl]

  results = []
  begin
    Timeout.timeout(timeout) do
      SIZE.each do |size|
        urls = create_urls(server, concurrent_number)
        results << multi_uploader(urls, size)
      end
    end
  rescue Timeout::Error # rubocop:disable Lint/SuppressedException
  end
  MeasureResult.new(results)
end