Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing docstrings for Base.Sys #52777

Merged
merged 36 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
424998b
Added Docstring for Base.sys :CPU_NAME,JIT,cpu_info,cpu_summary
11happy Jan 6, 2024
7fa4956
Removed Whitespace
11happy Jan 6, 2024
1205874
Incorporated suggestions as per documentation style
11happy Jan 7, 2024
d70aa64
Removed Jldoctest
11happy Jan 7, 2024
2e70a60
Update base/sysinfo.jl
11happy Jan 8, 2024
321f497
Update base/sysinfo.jl
11happy Jan 8, 2024
28df075
Update base/sysinfo.jl
11happy Jan 8, 2024
4e20ecc
Update base/sysinfo.jl
11happy Jan 8, 2024
aab0507
Suggested Changes
11happy Jan 8, 2024
f1a6291
Removed White Space
11happy Jan 8, 2024
e84a16a
Removed White Space
11happy Jan 8, 2024
2096423
Added show function
11happy Jan 11, 2024
3e63af5
Formatted the code
11happy Jan 11, 2024
3f38416
Fixed/Added Suggested Changes
11happy Jan 11, 2024
0a3cf6f
Removed WhiteSpace
11happy Jan 11, 2024
e11dfd9
Added Space
11happy Jan 11, 2024
eaf73a8
Added Proper Indent
11happy Jan 11, 2024
3f6bec7
Update base/sysinfo.jl
11happy Jan 11, 2024
88e6fae
Update base/sysinfo.jl
11happy Jan 11, 2024
f35cb86
suggested changed
11happy Jan 11, 2024
a41c271
Merge branch 'FourthPR' of https://github.com/11happy/julia into Four…
11happy Jan 11, 2024
526ac1e
Public CPUinfo,Added Tests for show
11happy Jan 12, 2024
60fdb2f
Update base/sysinfo.jl
11happy Jan 13, 2024
fc3d652
Update test/sysinfo.jl
11happy Jan 13, 2024
4b3722a
minor fixes
11happy Jan 13, 2024
8f84372
added cpu_summary method
11happy Jan 13, 2024
8d92a49
removed export of Sys.JIT,Sys.CPU_NAME,Sys.cpu_summary,Sys.cpu_info
11happy Jan 15, 2024
143169d
resolved merge conflict
11happy Jan 16, 2024
3309d86
Update base/sysinfo.jl
11happy Jan 16, 2024
5e2cdbd
Update test/sysinfo.jl
11happy Jan 16, 2024
06f5a4c
Update base/sysinfo.jl
11happy Jan 16, 2024
6cf7d26
Update base/sysinfo.jl
11happy Jan 16, 2024
718740e
Update base/sysinfo.jl
11happy Jan 16, 2024
adbf6b0
Update base/sysinfo.jl
11happy Jan 16, 2024
a391a4e
Formatted the code
11happy Jan 16, 2024
d4e3a3d
Update test/sysinfo.jl
stevengj Jan 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion base/sysinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,33 @@ Standard word size on the current machine, in bits.
"""
const WORD_SIZE = Core.sizeof(Int) * 8

global SC_CLK_TCK::Clong, CPU_NAME::String, JIT::String
global SC_CLK_TCK::Clong
11happy marked this conversation as resolved.
Show resolved Hide resolved

"""
stevengj marked this conversation as resolved.
Show resolved Hide resolved
Sys.CPU_NAME::String

A string representing the name of CPU.
stevengj marked this conversation as resolved.
Show resolved Hide resolved

# Examples
```
julia> Sys.CPU_NAME
"tigerlake"
```
stevengj marked this conversation as resolved.
Show resolved Hide resolved
"""
global CPU_NAME::String

"""
Sys.JIT::String

A string representing the specific Just-In-Time (JIT) compiler being utilized in the current runtime.
stevengj marked this conversation as resolved.
Show resolved Hide resolved

# Examples
```
julia> Sys.JIT
"ORCJIT"
```
11happy marked this conversation as resolved.
Show resolved Hide resolved
"""
global JIT::String

function __init__()
env_threads = nothing
Expand Down Expand Up @@ -201,6 +227,14 @@ function _cpu_summary(io::IO, cpu::AbstractVector{CPUinfo}, i, j)
println(io)
end

"""
Sys.cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo}=cpu_info())

Print a summary of CPU information, organizing and displaying aggregated data for CPUs with the same model.
11happy marked this conversation as resolved.
Show resolved Hide resolved

The summary includes aggregated information for each distinct CPU model,
providing details such as average CPU speed and total time spent in different modes (user, nice, sys, idle, irq) across all cores with the same model.
stevengj marked this conversation as resolved.
Show resolved Hide resolved
"""
function cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info())
model = cpu[1].model
first = 1
Expand All @@ -213,6 +247,21 @@ function cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info())
_cpu_summary(io, cpu, first, length(cpu))
end

"""
Sys.cpu_info()

Return a vector of `CPUinfo` objects, where each object represent information about a CPU core.
11happy marked this conversation as resolved.
Show resolved Hide resolved
11happy marked this conversation as resolved.
Show resolved Hide resolved

The function provides information about each CPU, including model, speed, and usage statistics such as user time, nice time, system time, idle time, and interrupt time.
The `CPUinfo` type is a mutable struct with the following fields:
Copy link
Member

@stevengj stevengj Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As commented earlier, if we are going to mention the CPUinfo type in the docstrings, then it becomes part of the public API, and there should at least be a

public CPUinfo

statement reflecting this, as well as moving this information about the struct into a docstring for CPUinfo (which then also goes in the manual).

- `model::String`: CPU model information.
- `speed::Int32`: CPU speed.
- `cpu_times!user::UInt64`: Time spent in user mode. CPU state shows CPU time used by user space processes.
- `cpu_times!nice::UInt64`: Time spent in nice mode. CPU state is a subset of the "user" state and shows the CPU time used by processes that have a positive niceness, meaning a lower priority than other tasks.
- `cpu_times!sys::UInt64`: Time spent in system mode. CPU state shows the amount of CPU time used by the kernel.
- `cpu_times!idle::UInt64`: Time spent in idle mode. CPU state shows the CPU time that's not actively being used.
- `cpu_times!irq::UInt64`: Time spent handling interrupts. CPU state shows the amount of time the CPU has been servicing hardware interrupts.
"""
function cpu_info()
UVcpus = Ref{Ptr{UV_cpu_info_t}}()
count = Ref{Int32}()
Expand Down
4 changes: 4 additions & 0 deletions doc/src/base/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ Base.@allocations
Base.EnvDict
Base.ENV
Base.Sys.STDLIB
Base.Sys.CPU_NAME
Base.Sys.JIT
Base.Sys.cpu_info
Base.Sys.cpu_summary
stevengj marked this conversation as resolved.
Show resolved Hide resolved
Base.Sys.isunix
Base.Sys.isapple
Base.Sys.islinux
Expand Down