1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

runtime: nr_cpus()

This commit is contained in:
Alexander Medvednikov
2019-10-11 06:36:46 +03:00
parent a280e98d7f
commit 52c2fa44b8
6 changed files with 24 additions and 5 deletions

13
vlib/runtime/runtime.v Normal file
View File

@ -0,0 +1,13 @@
// Copyright (c) 2019 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
module runtime
#include <sys/sysinfo.h>
fn C.get_nprocs() int
pub fn nr_cpus() int {
return C.get_nprocs()
}

View File

@ -0,0 +1,7 @@
import runtime
fn test_nr_cpus() {
nr_cpus := runtime.nr_cpus()
println(nr_cpus)
assert nr_cpus > 0
}