Repository navigation
Expand file tree
/
Copy pathos.ts
More file actions
73 lines (62 loc) · 1.79 KB
/
Copy pathos.ts
File metadata and controls
73 lines (62 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Synchronous host OS metadata used in the MongoDB handshake document.
/** @gea-host-inert */
declare function __gea_node_platform(): string
/** @gea-host-inert */
declare function __gea_node_os_arch(): string
/** @gea-host-inert */
declare function __gea_node_os_release(): string
/** @gea-host-inert */
declare function __gea_node_os_type(): string
/** @gea-host-inert */
declare function __gea_node_os_available_parallelism(): number
function nodeOsPlatform(): string {
return __gea_node_platform()
}
function nodeOsArch(): string {
return __gea_node_os_arch()
}
function nodeOsRelease(): string {
return __gea_node_os_release()
}
function nodeOsType(): string {
return __gea_node_os_type()
}
function nodeOsEndianness(): 'LE' | 'BE' {
// geatsc's supported native targets are currently little-endian.
return 'LE'
}
function nodeOsAvailableParallelism(): number {
return __gea_node_os_available_parallelism()
}
export interface CpuTimes {
user: number
nice: number
sys: number
idle: number
irq: number
}
export interface CpuInfo {
model: string
speed: number
times: CpuTimes
}
// One entry per online logical CPU. The per-CPU model, clock and time
// counters are not read on this target; `cpus().length` is the fact programs
// reach for (a worker count), and that one is real.
function nodeOsCpus(): CpuInfo[] {
const count = __gea_node_os_available_parallelism()
const cpus: CpuInfo[] = []
for (let index = 0; index < count; index += 1) {
cpus.push({ model: '', speed: 0, times: { user: 0, nice: 0, sys: 0, idle: 0, irq: 0 } })
}
return cpus
}
export {
nodeOsAvailableParallelism as availableParallelism,
nodeOsCpus as cpus,
nodeOsPlatform as platform,
nodeOsArch as arch,
nodeOsRelease as release,
nodeOsType as type,
nodeOsEndianness as endianness
}