Class: SpeedtestNet::CalculateSpeed
- Inherits:
-
Object
- Object
- SpeedtestNet::CalculateSpeed
- Defined in:
- lib/speedtest_net/calculate_speed.rb
Class Method Summary collapse
-
.call(results) ⇒ Object
Fastest 10% and slowest 30% of results are then discarded See: support.ookla.com/hc/en-us/articles/234575828-What-is-the-test-flow-and-methodology-for-the-Speedtest-.
Class Method Details
.call(results) ⇒ Object
Fastest 10% and slowest 30% of results are then discarded See: support.ookla.com/hc/en-us/articles/234575828-What-is-the-test-flow-and-methodology-for-the-Speedtest-
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/speedtest_net/calculate_speed.rb', line 8 def call(results) sorted_results = sorted_nemric_results(results) count = sorted_results.count return 0.0 if count.zero? faster = count - (count * 0.1).round # fastest 10% slower = (count * 0.3).round # slowest 30% target_results = sorted_results[slower...faster] # The remaining result are averaged together to determine # the final result target_results.sum.to_f / target_results.count end |