2020-06-17 03:34:16 +03:00
|
|
|
import net.http
|
|
|
|
import sync
|
|
|
|
import time
|
|
|
|
|
2022-10-16 09:28:57 +03:00
|
|
|
fn vlang_time(mut wg sync.WaitGroup) !string {
|
2020-06-17 03:34:16 +03:00
|
|
|
start := time.ticks()
|
2022-10-16 09:28:57 +03:00
|
|
|
data := http.get('https://vlang.io/utc_now')!
|
2020-06-17 03:34:16 +03:00
|
|
|
finish := time.ticks()
|
2020-07-29 20:11:08 +03:00
|
|
|
println('Finish getting time ${finish - start} ms')
|
2022-05-29 20:27:18 +03:00
|
|
|
println(data.body)
|
2020-06-17 03:34:16 +03:00
|
|
|
wg.done()
|
2022-05-29 20:27:18 +03:00
|
|
|
return data.body
|
2020-06-17 03:34:16 +03:00
|
|
|
}
|
|
|
|
|
2022-10-16 09:28:57 +03:00
|
|
|
fn remote_ip(mut wg sync.WaitGroup) !string {
|
2020-06-17 03:34:16 +03:00
|
|
|
start := time.ticks()
|
2022-10-16 09:28:57 +03:00
|
|
|
data := http.get('https://api.ipify.org')!
|
2020-06-17 03:34:16 +03:00
|
|
|
finish := time.ticks()
|
2020-07-29 20:11:08 +03:00
|
|
|
println('Finish getting ip ${finish - start} ms')
|
2022-05-29 20:27:18 +03:00
|
|
|
println(data.body)
|
2020-06-17 03:34:16 +03:00
|
|
|
wg.done()
|
2022-05-29 20:27:18 +03:00
|
|
|
return data.body
|
2020-06-17 03:34:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2020-07-24 13:29:47 +03:00
|
|
|
mut wg := sync.new_waitgroup()
|
2020-06-17 03:34:16 +03:00
|
|
|
wg.add(2)
|
|
|
|
// Run tasks async
|
2022-11-05 10:46:40 +03:00
|
|
|
spawn vlang_time(mut wg)
|
|
|
|
spawn remote_ip(mut wg)
|
2020-06-17 03:34:16 +03:00
|
|
|
wg.wait()
|
|
|
|
}
|