2020-11-15 21:54:47 +01:00
|
|
|
import net.http
|
|
|
|
import sync
|
|
|
|
import time
|
|
|
|
|
|
|
|
fn send_request(mut wg sync.WaitGroup) ?string {
|
2021-02-23 18:43:44 +01:00
|
|
|
start := time.ticks()
|
2022-05-13 05:56:21 +02:00
|
|
|
data := http.get('https://google.com')?
|
2021-02-23 18:43:44 +01:00
|
|
|
finish := time.ticks()
|
|
|
|
println('Finish getting time ${finish - start} ms')
|
|
|
|
wg.done()
|
|
|
|
return data.text
|
2020-11-15 21:54:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2021-02-23 18:43:44 +01:00
|
|
|
mut wg := sync.new_waitgroup()
|
|
|
|
for i := 0; i < 50; i++ {
|
|
|
|
wg.add(1)
|
|
|
|
go send_request(mut wg)
|
|
|
|
}
|
|
|
|
wg.wait()
|
2020-11-15 21:54:47 +01:00
|
|
|
}
|