2020-06-17 02:34:16 +02:00
|
|
|
import net.http
|
|
|
|
import sync
|
|
|
|
import time
|
|
|
|
|
2020-07-24 12:29:47 +02:00
|
|
|
fn vlang_time(mut wg sync.WaitGroup) ?string {
|
2020-06-17 02:34:16 +02:00
|
|
|
start := time.ticks()
|
|
|
|
data := http.get('https://vlang.io/utc_now')?
|
|
|
|
finish := time.ticks()
|
2020-07-29 19:11:08 +02:00
|
|
|
println('Finish getting time ${finish - start} ms')
|
2020-06-17 02:34:16 +02:00
|
|
|
println(data.text)
|
|
|
|
wg.done()
|
|
|
|
return data.text
|
|
|
|
}
|
|
|
|
|
2020-07-24 12:29:47 +02:00
|
|
|
fn remote_ip(mut wg sync.WaitGroup) ?string {
|
2020-06-17 02:34:16 +02:00
|
|
|
start := time.ticks()
|
|
|
|
data := http.get('https://api.ipify.org')?
|
|
|
|
finish := time.ticks()
|
2020-07-29 19:11:08 +02:00
|
|
|
println('Finish getting ip ${finish - start} ms')
|
2020-06-17 02:34:16 +02:00
|
|
|
println(data.text)
|
|
|
|
wg.done()
|
|
|
|
return data.text
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2020-07-24 12:29:47 +02:00
|
|
|
mut wg := sync.new_waitgroup()
|
2020-06-17 02:34:16 +02:00
|
|
|
wg.add(2)
|
|
|
|
// Run tasks async
|
2020-07-24 12:29:47 +02:00
|
|
|
go vlang_time(mut wg)
|
|
|
|
go remote_ip(mut wg)
|
2020-06-17 02:34:16 +02:00
|
|
|
wg.wait()
|
|
|
|
}
|