v / examples
Raw file | 21 loc (19 sloc) | 391 bytes | Latest commit hash e81e0ac70
1import net.http
2import sync
3import time
4
5fn send_request(mut wg sync.WaitGroup) !string {
6 start := time.ticks()
7 data := http.get('https://google.com')!
8 finish := time.ticks()
9 println('Finish getting time ${finish - start} ms')
10 wg.done()
11 return data.body
12}
13
14fn main() {
15 mut wg := sync.new_waitgroup()
16 for i := 0; i < 50; i++ {
17 wg.add(1)
18 spawn send_request(mut wg)
19 }
20 wg.wait()
21}