2020-11-15 23:54:47 +03:00
|
|
|
import net.http
|
|
|
|
import sync
|
|
|
|
import time
|
|
|
|
|
2022-10-16 09:28:57 +03:00
|
|
|
fn send_request(mut wg sync.WaitGroup) !string {
|
2021-02-23 20:43:44 +03:00
|
|
|
start := time.ticks()
|
2022-10-16 09:28:57 +03:00
|
|
|
data := http.get('https://google.com')!
|
2021-02-23 20:43:44 +03:00
|
|
|
finish := time.ticks()
|
|
|
|
println('Finish getting time ${finish - start} ms')
|
|
|
|
wg.done()
|
2022-05-29 20:27:18 +03:00
|
|
|
return data.body
|
2020-11-15 23:54:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2021-02-23 20:43:44 +03:00
|
|
|
mut wg := sync.new_waitgroup()
|
|
|
|
for i := 0; i < 50; i++ {
|
|
|
|
wg.add(1)
|
2022-11-05 10:46:40 +03:00
|
|
|
spawn send_request(mut wg)
|
2021-02-23 20:43:44 +03:00
|
|
|
}
|
|
|
|
wg.wait()
|
2020-11-15 23:54:47 +03:00
|
|
|
}
|