@std/os/system.ms#
Import each required symbol with import Name from "@std/os/system.ms".
CpuInfo Type#
Model, integer MHz speed (fractional MHz truncated), and cumulative integer millisecond counters for one logical CPU. irq includes hardware and software interrupt time.
type CpuInfo {
model String
speed_mhz Int
user Int
nice Int
system Int
idle Int
irq Int
}CpuInfo.idle#
Cumulative milliseconds this logical CPU spent idle.
idle IntCpuInfo.irq#
Cumulative milliseconds this logical CPU spent servicing hardware and software interrupts.
irq IntCpuInfo.model#
Marketing name of the processor, such as Intel(R) Core(TM) i7; it can be empty
where the host does not report one.
model StringCpuInfo.nice#
Cumulative milliseconds this logical CPU spent running low-priority (niced) user processes.
nice IntCpuInfo.speed_mhz#
Integer megahertz, not a time interval.
speed_mhz IntCpuInfo.system#
Cumulative milliseconds this logical CPU spent running kernel code.
system IntCpuInfo.user#
Cumulative milliseconds this logical CPU spent running normal-priority user processes.
user IntEndianness Enum#
The byte order of the host’s native integers.
enum Endianness {
Little
Big
}Endianness.Big#
The most significant byte comes first.
BigEndianness.Little#
The least significant byte comes first, as on x86-64 and AArch64.
LittleMemoryUsage Type#
Memory statistics for the current process; every field is bytes.
type MemoryUsage {
heap_used Int
heap_total Int
heap_system Int
external Int
resident Int
}MemoryUsage.external#
Bytes the runtime obtained from the operating system outside the heap, such as stacks and internal tables.
external IntMemoryUsage.heap_system#
Bytes of heap memory obtained from the operating system, including idle spans.
heap_system IntMemoryUsage.heap_total#
Bytes of heap spans currently in use, which is at least heap_used.
heap_total IntMemoryUsage.heap_used#
Bytes of heap memory occupied by live objects and objects not yet collected.
heap_used IntMemoryUsage.resident#
Bytes of physical memory the operating system reports as resident for the process.
resident IntNetworkInterface Type#
Address and link metadata for one host network interface.
type NetworkInterface {
name String
address String
netmask String
family IpFamily
mac String
internal Bool
scope_id Int
}NetworkInterface.address#
The interface’s IP address in textual form, such as 192.168.1.5 or fe80::1.
address StringNetworkInterface.family#
Whether address is IPv4 or IPv6.
family IpFamilyNetworkInterface.internal#
True for a loopback interface, which only reaches the local host.
internal BoolNetworkInterface.mac#
Hardware address as colon-separated lowercase hexadecimal, or an empty string for interfaces without one such as loopback.
mac StringNetworkInterface.name#
Host name of the interface, such as eth0 or lo0. Interfaces with several
addresses appear once per address.
name StringNetworkInterface.netmask#
The address’s network mask in the same textual form as address, such as
255.255.255.0.
netmask StringNetworkInterface.scope_id#
The operating system’s numeric index for the interface, as used to select an interface for link-local IPv6 addresses.
scope_id IntOs Enum#
The operating system family the program was built for. A host outside the three named
families reads as Other.
enum Os {
Linux
Macos
Windows
Other
}Os.Linux#
The program runs on a Linux kernel of any distribution.
LinuxOs.Macos#
The program runs on Apple macOS, which uname reports as Darwin.
MacosOs.Other#
The host is outside the three named families, such as a BSD.
OtherOs.Windows#
The program runs on Microsoft Windows, where numeric user ids read as -1.
WindowsRuntimeCounts Type#
Work the runtime has done since the program started. Counts only grow, so a benchmark reads them before and after a run and subtracts. They do not depend on machine load or on the host, so a change in them is a real change in the work a program does.
type RuntimeCounts {
allocations Int
allocated_bytes Int
list_copies Int
list_copy_bytes Int
string_clones Int
string_clone_bytes Int
operations Int
}RuntimeCounts.allocated_bytes#
Bytes those allocations asked for.
allocated_bytes IntRuntimeCounts.allocations#
Allocations the runtime made. Covers the calling thread and every thread that has finished; a thread still running is not included.
allocations IntRuntimeCounts.list_copies#
Lists copied element by element, from the calling isolate.
list_copies IntRuntimeCounts.list_copy_bytes#
Bytes those list copies moved.
list_copy_bytes IntRuntimeCounts.operations#
MIR operations the program executed: its own code, not the runtime beneath it.
Counted only in a build made for it (ms bench --ops); zero otherwise.
operations IntRuntimeCounts.string_clone_bytes#
Bytes those string clones moved.
string_clone_bytes IntRuntimeCounts.string_clones#
Strings cloned, from the calling isolate.
string_clones IntSystemInfo Type#
Operating system and processor architecture for the current host.
type SystemInfo {
os String
architecture String
cpu_count Int
}SystemInfo.architecture#
The processor architecture in common naming, such as amd64, arm64, or 386.
architecture StringSystemInfo.cpu_count#
Number of logical CPUs the operating system reports as present for this process.
cpu_count IntSystemInfo.os#
Operating system name, such as linux, darwin, or windows. Hosts outside those
families report their own name; os() returns the three named families as an
enum.
os StringSystemMetrics Type#
Host measurements: memory fields are bytes; load_average is 1/5/15-minute load (three zeros on Windows); available_parallelism is a usable logical-processor count.
type SystemMetrics {
total_memory Int
free_memory Int
available_memory Int
uptime Duration
load_average List[Float]
available_parallelism Int
}SystemMetrics.available_memory#
Estimated physical memory in bytes that new work can use without swapping, including reclaimable caches.
available_memory IntSystemMetrics.available_parallelism#
Logical processors this process may run on, which can be fewer than
SystemInfo.cpu_count under CPU affinity limits.
available_parallelism IntSystemMetrics.free_memory#
Physical memory in bytes that is completely unused; caches count as used, so it
is usually smaller than available_memory.
free_memory IntSystemMetrics.load_average#
Three Floats for the 1, 5, and 15 minute system load averages; all 0.0 on Windows.
load_average List[Float]SystemMetrics.total_memory#
Installed physical memory in bytes.
total_memory IntSystemMetrics.uptime#
Host boot uptime as a Duration with whole-second native resolution; not process uptime.
uptime DurationUserInfo Type#
User name, numeric identity, home directory, and login shell.
type UserInfo {
username String
uid Int
gid Int
home String
shell String
}UserInfo.gid#
Numeric primary group id of the current user; -1 on Windows, where ids are not numeric.
gid IntUserInfo.home#
Absolute path of the user’s home directory from the account database.
home StringUserInfo.shell#
Path of the user’s login shell, or an empty string when the host records null.
shell StringUserInfo.uid#
Numeric user id of the current user; -1 on Windows, where ids are not numeric.
uid IntUserInfo.username#
Login name of the current user.
username Stringavailable_memory Function#
Returns bytes available to new allocations: the host’s available memory, reduced to the remaining headroom when a Linux cgroup memory limit applies.
fn available_memory() Result[Int, Error] { ... }constants Function#
Returns native signal/error/loader/priority constants by name. Names and values vary by host; missing entries do not imply a portable numeric default.
fn constants() Map[String, Int] { ... }constrained_memory Function#
Returns the memory limit in bytes imposed on this process by its Linux cgroup, or 0 when no limit applies or the platform has no such limit.
fn constrained_memory() Result[Int, Error] { ... }cpus Function#
Returns one CpuInfo per logical CPU with its model, clock speed, and cumulative time counters.
fn cpus() Result[List[CpuInfo], Error] { ... }dev_null Function#
Returns the conventional null-device path for the host.
fn dev_null() String { ... }end_of_line Function#
Returns the host’s line-ending sequence.
fn end_of_line() String { ... }endianness Function#
Returns the host’s native byte order.
fn endianness() Endianness { ... }hostname Function#
Returns the host’s name as reported by the operating system. A name that is not valid UTF-8 returns ENOTSUP.
fn hostname() Result[String, Error] { ... }machine Function#
Returns the hardware architecture in uname -m style, such as x86_64, aarch64,
or i686; other architectures use the target’s architecture name.
fn machine() Result[String, Error] { ... }memory_usage Function#
Returns heap and resident memory statistics for this process, in bytes.
fn memory_usage() Result[MemoryUsage, Error] { ... }metrics Function#
Returns memory sizes in bytes, host uptime, load averages, and available parallelism
in one snapshot. A host query failure returns an Error describing it.
fn metrics() Result[SystemMetrics, Error] { ... }network_interfaces Function#
Returns one NetworkInterface for every address on every interface, including loopback. An interface name that is not valid UTF-8 returns ENOTSUP.
fn network_interfaces() Result[List[NetworkInterface], Error] { ... }os Function#
Returns the operating system family this program runs on.
fn os() Os { ... }os_release Function#
Returns the kernel release string, such as 6.1.0-18-amd64, with surrounding
whitespace removed. Returns ENOTSUP where the host does not expose it.
fn os_release() Result[String, Error] { ... }os_version Function#
Returns the kernel build or version string, such as #1 SMP Debian, with surrounding
whitespace removed. Returns ENOTSUP where the host does not expose it.
fn os_version() Result[String, Error] { ... }runtime_counts Function#
Returns the runtime’s work counters: allocations, bytes allocated, and list and string copies.
fn runtime_counts() Result[RuntimeCounts, Error] { ... }system_info Function#
Returns the operating system name, processor architecture, and logical CPU count for this host.
fn system_info() SystemInfo { ... }uptime Function#
Returns elapsed Duration since runtime initialization, rather than host boot.
fn uptime() Result[Duration, Error] { ... }user_info Function#
Returns the current user’s name, numeric ids, home directory, and login shell. The shell is empty when the host does not record one, and text that is not valid UTF-8 returns ENOTSUP.
fn user_info() Result[UserInfo, Error] { ... }