benchmark runs the benchmark and returns the measured download speeds.
(l *zerolog.Logger, name string, urls []string, n int)
| 99 | |
| 100 | // benchmark runs the benchmark and returns the measured download speeds. |
| 101 | func benchmark(l *zerolog.Logger, name string, urls []string, n int) ([]float64, float64) { |
| 102 | log := l.With().Str("mode", name).Logger() |
| 103 | |
| 104 | // Group the SAS URLs randomly into groups of size n |
| 105 | groups := math.RandomizedGroups(urls, n) |
| 106 | |
| 107 | // Download the SAS URLs in each group and measure the download speed |
| 108 | var speeds []float64 |
| 109 | failures := 0 |
| 110 | |
| 111 | var wg sync.WaitGroup |
| 112 | for _, group := range groups { |
| 113 | wg.Add(1) |
| 114 | go func(group []string) { |
| 115 | defer wg.Done() |
| 116 | s, f := downloadSASURLs(&log, group) |
| 117 | speeds = append(speeds, s...) |
| 118 | failures += f |
| 119 | }(group) |
| 120 | } |
| 121 | |
| 122 | wg.Wait() |
| 123 | |
| 124 | // Calculate the percentiles |
| 125 | return math.PercentilesFloat64Reverse(speeds, 0.50, 0.75, 0.9, 0.99, 1), float64(failures) / float64(len(urls)) |
| 126 | } |
| 127 | |
| 128 | // getP2pSasUrls returns the SAS URLs for the p2p network |
| 129 | func getP2pSasUrls(upstreamSasUrls []string, proxyHost string) []string { |
no test coverage detected