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:
parent
a280e98d7f
commit
52c2fa44b8
@ -31,7 +31,6 @@ struct VargAccess {
|
|||||||
index int
|
index int
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
enum NameCategory {
|
enum NameCategory {
|
||||||
constant
|
constant
|
||||||
mod
|
mod
|
||||||
@ -41,8 +40,8 @@ enum NameCategory {
|
|||||||
|
|
||||||
struct Name {
|
struct Name {
|
||||||
cat NameCategory
|
cat NameCategory
|
||||||
|
idx int // e.g. typ := types[name.idx]
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
struct GenTable {
|
struct GenTable {
|
||||||
fn_name string
|
fn_name string
|
||||||
|
@ -35,7 +35,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
fn new_hashmap(planned_nr_items int) hashmap {
|
fn new_hashmap(planned_nr_items int) hashmap {
|
||||||
mut cap := planned_nr_items * 3
|
mut cap := planned_nr_items * 5
|
||||||
if cap < min_cap {
|
if cap < min_cap {
|
||||||
cap = min_cap
|
cap = min_cap
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ pub fn (m &map) keys() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn (m map) get(key string, out voidptr) bool {
|
fn (m map) get(key string, out voidptr) bool {
|
||||||
//println('g')
|
println('g')
|
||||||
if m.root == 0 {
|
if m.root == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
13
vlib/runtime/runtime.v
Normal file
13
vlib/runtime/runtime.v
Normal 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()
|
||||||
|
}
|
7
vlib/runtime/runtime_test.v
Normal file
7
vlib/runtime/runtime_test.v
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import runtime
|
||||||
|
|
||||||
|
fn test_nr_cpus() {
|
||||||
|
nr_cpus := runtime.nr_cpus()
|
||||||
|
println(nr_cpus)
|
||||||
|
assert nr_cpus > 0
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user