From 424998ba610db4329541232f84bf9a83c21199e9 Mon Sep 17 00:00:00 2001 From: 11happy Date: Sat, 6 Jan 2024 18:20:30 +0530 Subject: [PATCH 01/34] Added Docstring for Base.sys :CPU_NAME,JIT,cpu_info,cpu_summary Signed-off-by: 11happy --- base/sysinfo.jl | 49 +++++++++++++++++++++++++++++++++++++++++++- doc/src/base/base.md | 4 ++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 53835366d3171..df32fddcdb8c5 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -98,7 +98,19 @@ 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 +""" + Sys.CPU_NAME::String + +A string representing the name of CPU. +""" +global CPU_NAME::String +""" + Sys.JIT::String + +A string representing the specific Just-In-Time (JIT) compiler being utilized in the current runtime. +""" +global JIT::String function __init__() env_threads = nothing @@ -201,6 +213,20 @@ function _cpu_summary(io::IO, cpu::AbstractVector{CPUinfo}, i, j) println(io) end +""" + Sys.cpu_summary() + +Prints a summary of CPU information, organizing and displaying aggregated data for CPUs with the same model. + +# Arguments +- `io::IO`: Output stream where the summary will be printed (default is `stdout`). +- `cpu::AbstractVector{CPUinfo}`: Vector of `CPUinfo` objects containing detailed information about each CPU (default is obtained from `cpu_info()`). + +# Output +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. + +""" function cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info()) model = cpu[1].model first = 1 @@ -213,6 +239,27 @@ function cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info()) _cpu_summary(io, cpu, first, length(cpu)) end +""" + Sys.cpu_info() + +Retrieves detailed information about the CPUs on the current system. + +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. + +# Returns +- A vector of `CPUinfo` objects, where each object represents information about a CPU core. + +# CPUinfo Type +The `CPUinfo` type is a mutable struct with the following fields: +- `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}() diff --git a/doc/src/base/base.md b/doc/src/base/base.md index 7172474b40b39..f91863a3b56d4 100644 --- a/doc/src/base/base.md +++ b/doc/src/base/base.md @@ -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 Base.Sys.isunix Base.Sys.isapple Base.Sys.islinux From 7fa495651f44a6483b170551afa262a3b87fa7bd Mon Sep 17 00:00:00 2001 From: 11happy Date: Sat, 6 Jan 2024 18:29:44 +0530 Subject: [PATCH 02/34] Removed Whitespace Signed-off-by: 11happy --- base/sysinfo.jl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index df32fddcdb8c5..2fd2a73a59271 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -212,7 +212,6 @@ function _cpu_summary(io::IO, cpu::AbstractVector{CPUinfo}, i, j) end println(io) end - """ Sys.cpu_summary() @@ -225,7 +224,6 @@ Prints a summary of CPU information, organizing and displaying aggregated data f # Output 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. - """ function cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info()) model = cpu[1].model @@ -238,7 +236,6 @@ function cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info()) end _cpu_summary(io, cpu, first, length(cpu)) end - """ Sys.cpu_info() @@ -258,7 +255,6 @@ The `CPUinfo` type is a mutable struct with the following fields: - `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}}() From 1205874b61c2a3ebdcfe5ed569c2fd30eb1f7341 Mon Sep 17 00:00:00 2001 From: 11happy Date: Sun, 7 Jan 2024 17:55:10 +0530 Subject: [PATCH 03/34] Incorporated suggestions as per documentation style Signed-off-by: 11happy --- base/sysinfo.jl | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 2fd2a73a59271..93609eec3d5af 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -99,16 +99,30 @@ Standard word size on the current machine, in bits. const WORD_SIZE = Core.sizeof(Int) * 8 global SC_CLK_TCK::Clong + """ Sys.CPU_NAME::String A string representing the name of CPU. + +# Examples +```jldoctest +julia> Sys.CPU_NAME +"tigerlake" +``` """ global CPU_NAME::String + """ Sys.JIT::String A string representing the specific Just-In-Time (JIT) compiler being utilized in the current runtime. + +# Examples +```jldoctest +julia> Sys.JIT +"ORCJIT" +``` """ global JIT::String @@ -212,16 +226,12 @@ function _cpu_summary(io::IO, cpu::AbstractVector{CPUinfo}, i, j) end println(io) end -""" - Sys.cpu_summary() -Prints a summary of CPU information, organizing and displaying aggregated data for CPUs with the same model. +""" + Sys.cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo}=cpu_info()) -# Arguments -- `io::IO`: Output stream where the summary will be printed (default is `stdout`). -- `cpu::AbstractVector{CPUinfo}`: Vector of `CPUinfo` objects containing detailed information about each CPU (default is obtained from `cpu_info()`). +Print a summary of CPU information, organizing and displaying aggregated data for CPUs with the same model. -# Output 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. """ @@ -236,22 +246,18 @@ function cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info()) end _cpu_summary(io, cpu, first, length(cpu)) end + """ Sys.cpu_info() -Retrieves detailed information about the CPUs on the current system. +Return a vector of `CPUinfo` objects, where each object represent information about a CPU core. 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. - -# Returns -- A vector of `CPUinfo` objects, where each object represents information about a CPU core. - -# CPUinfo Type The `CPUinfo` type is a mutable struct with the following fields: - `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!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. From d70aa64b8e6a6c5dd302d9a1679ab8a6da2739cc Mon Sep 17 00:00:00 2001 From: 11happy Date: Sun, 7 Jan 2024 18:25:22 +0530 Subject: [PATCH 04/34] Removed Jldoctest Signed-off-by: 11happy --- base/sysinfo.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 93609eec3d5af..bc8c2a973364e 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -106,7 +106,7 @@ global SC_CLK_TCK::Clong A string representing the name of CPU. # Examples -```jldoctest +``` julia> Sys.CPU_NAME "tigerlake" ``` @@ -119,7 +119,7 @@ global CPU_NAME::String A string representing the specific Just-In-Time (JIT) compiler being utilized in the current runtime. # Examples -```jldoctest +``` julia> Sys.JIT "ORCJIT" ``` From 2e70a60a4609625762fb498e75331d890cb7616f Mon Sep 17 00:00:00 2001 From: Bhuminjay Soni <76656712+11happy@users.noreply.github.com> Date: Mon, 8 Jan 2024 18:20:03 +0530 Subject: [PATCH 05/34] Update base/sysinfo.jl Co-authored-by: Steven G. Johnson --- base/sysinfo.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index bc8c2a973364e..73118b366aab8 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -251,6 +251,8 @@ end Sys.cpu_info() Return a vector of `CPUinfo` objects, where each object represent information about a CPU core. +This is displayed in a tabular format by the REPL, so most users will not need to access the `CPUinfo` +data structures directly. 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: From 321f497c6068a3671b0a70761d4c3bffc1a69314 Mon Sep 17 00:00:00 2001 From: Bhuminjay Soni <76656712+11happy@users.noreply.github.com> Date: Mon, 8 Jan 2024 18:20:14 +0530 Subject: [PATCH 06/34] Update base/sysinfo.jl Co-authored-by: Steven G. Johnson --- base/sysinfo.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 73118b366aab8..8de9b5ef7a1d2 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -122,7 +122,8 @@ A string representing the specific Just-In-Time (JIT) compiler being utilized in ``` julia> Sys.JIT "ORCJIT" -``` +Currently, this returns `"ORCJIT"` for the LLVM "ORC" ("On-Request Compilation") JIT library: +```jldoctest """ global JIT::String From 28df075764342fd1b63c509ca797a29374ce26fc Mon Sep 17 00:00:00 2001 From: Bhuminjay Soni <76656712+11happy@users.noreply.github.com> Date: Mon, 8 Jan 2024 18:20:26 +0530 Subject: [PATCH 07/34] Update base/sysinfo.jl Co-authored-by: Steven G. Johnson --- base/sysinfo.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 8de9b5ef7a1d2..95eb6afa934b6 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -231,7 +231,8 @@ 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. +Print a summary of CPU information to the `io` stream (defaulting to [`stdout`](@ref)), organizing and displaying aggregated data for CPUs with the same model, for a given array of `CPUinfo` data structures +describing a set of CPUs (which defaults to the return value of the [`Sys.cpuinfo`](@ref) function). 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. From 4e20ecc6a148fa2b6a88e590ee8d64ad8e89b3c3 Mon Sep 17 00:00:00 2001 From: Bhuminjay Soni <76656712+11happy@users.noreply.github.com> Date: Mon, 8 Jan 2024 18:31:24 +0530 Subject: [PATCH 08/34] Update base/sysinfo.jl Co-authored-by: Steven G. Johnson --- base/sysinfo.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 95eb6afa934b6..683937a1cef5c 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -119,11 +119,11 @@ global CPU_NAME::String A string representing the specific Just-In-Time (JIT) compiler being utilized in the current runtime. # Examples -``` -julia> Sys.JIT -"ORCJIT" Currently, this returns `"ORCJIT"` for the LLVM "ORC" ("On-Request Compilation") JIT library: ```jldoctest +julia> Sys.JIT +"ORCJIT" +``` """ global JIT::String From aab05070bacd185622bfc2ad7bf94f4a4c0ef1d1 Mon Sep 17 00:00:00 2001 From: 11happy Date: Mon, 8 Jan 2024 18:47:45 +0530 Subject: [PATCH 09/34] Suggested Changes Signed-off-by: 11happy --- base/sysinfo.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 683937a1cef5c..d47b754e4fc19 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -106,10 +106,10 @@ global SC_CLK_TCK::Clong A string representing the name of CPU. # Examples -``` -julia> Sys.CPU_NAME -"tigerlake" -``` +For example, `Sys.CPU_NAME` might equal `"tigerlake"` on an +[Intel Core "Tiger Lake" CPU](https://en.wikipedia.org/wiki/Tiger_Lake), +or `"apple-m1"` on an [Apple M1 CPU](https://en.wikipedia.org/wiki/Apple_M1). + """ global CPU_NAME::String @@ -232,7 +232,7 @@ end Sys.cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo}=cpu_info()) Print a summary of CPU information to the `io` stream (defaulting to [`stdout`](@ref)), organizing and displaying aggregated data for CPUs with the same model, for a given array of `CPUinfo` data structures -describing a set of CPUs (which defaults to the return value of the [`Sys.cpuinfo`](@ref) function). +describing a set of CPUs (which defaults to the return value of the [`Sys.cpu_info`](@ref) function). 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. From f1a62910179d8ee89f452b2c156e8759de1298f0 Mon Sep 17 00:00:00 2001 From: 11happy Date: Mon, 8 Jan 2024 18:53:18 +0530 Subject: [PATCH 10/34] Removed White Space Signed-off-by: 11happy --- base/sysinfo.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index d47b754e4fc19..5afda5577e907 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -109,7 +109,6 @@ A string representing the name of CPU. For example, `Sys.CPU_NAME` might equal `"tigerlake"` on an [Intel Core "Tiger Lake" CPU](https://en.wikipedia.org/wiki/Tiger_Lake), or `"apple-m1"` on an [Apple M1 CPU](https://en.wikipedia.org/wiki/Apple_M1). - """ global CPU_NAME::String From e84a16a9c38710b5f545bbcd23cd528750c79860 Mon Sep 17 00:00:00 2001 From: 11happy Date: Mon, 8 Jan 2024 18:53:22 +0530 Subject: [PATCH 11/34] Removed White Space Signed-off-by: 11happy --- base/sysinfo.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 5afda5577e907..e494204f1cabc 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -106,7 +106,7 @@ global SC_CLK_TCK::Clong A string representing the name of CPU. # Examples -For example, `Sys.CPU_NAME` might equal `"tigerlake"` on an +For example, `Sys.CPU_NAME` might equal `"tigerlake"` on an [Intel Core "Tiger Lake" CPU](https://en.wikipedia.org/wiki/Tiger_Lake), or `"apple-m1"` on an [Apple M1 CPU](https://en.wikipedia.org/wiki/Apple_M1). """ From 2096423e7b5dc3bf69604a070d907f2aabfdc7d4 Mon Sep 17 00:00:00 2001 From: 11happy Date: Thu, 11 Jan 2024 15:40:50 +0530 Subject: [PATCH 12/34] Added show function Signed-off-by: 11happy --- base/sysinfo.jl | 15 +++++++++++++++ doc/src/base/base.md | 1 + 2 files changed, 16 insertions(+) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index e494204f1cabc..132fe806efd17 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -32,9 +32,11 @@ export BINDIR, isunix, iswindows, isjsvm, + show, isexecutable, username, which + import ..Base: show @@ -640,5 +642,18 @@ function username() isempty(pw.username) && Base.uv_error("username", Base.UV_ENOENT) return pw.username end +""" + Sys.show(io::IO, ::MIME"text/plain", cpu::AbstractVector{CPUinfo}) + +Print a summary of CPU information to the `io` stream (defaulting to [`stdout`](@ref)), +organizing and displaying aggregated data for CPUs with the same model, +for a given array of `CPUinfo` data structures. + +""" +function show(io::IO,::MIME"text/plain",cpu::AbstractVector{CPUinfo}) + summary(io, cpu) + println(io, ':') + cpu_summary(io, cpu) +end end # module Sys diff --git a/doc/src/base/base.md b/doc/src/base/base.md index f91863a3b56d4..26713294046e7 100644 --- a/doc/src/base/base.md +++ b/doc/src/base/base.md @@ -378,6 +378,7 @@ Base.Sys.isjsvm Base.Sys.loadavg Base.Sys.isexecutable Base.Sys.username +Base.Sys.show Base.@static ``` From 3e63af56691f3f8dec63793d0259ce3f837eca3b Mon Sep 17 00:00:00 2001 From: 11happy Date: Thu, 11 Jan 2024 15:47:30 +0530 Subject: [PATCH 13/34] Formatted the code Signed-off-by: 11happy --- base/sysinfo.jl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 132fe806efd17..5342f27f4501f 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -36,7 +36,6 @@ export BINDIR, isexecutable, username, which - import ..Base: show @@ -645,10 +644,9 @@ end """ Sys.show(io::IO, ::MIME"text/plain", cpu::AbstractVector{CPUinfo}) -Print a summary of CPU information to the `io` stream (defaulting to [`stdout`](@ref)), -organizing and displaying aggregated data for CPUs with the same model, +Print a summary of CPU information to the `io` stream (defaulting to [`stdout`](@ref)), +organizing and displaying aggregated data for CPUs with the same model, for a given array of `CPUinfo` data structures. - """ function show(io::IO,::MIME"text/plain",cpu::AbstractVector{CPUinfo}) summary(io, cpu) From 3f38416006a57b588b16b682c5ba76f8f55e28ef Mon Sep 17 00:00:00 2001 From: 11happy Date: Thu, 11 Jan 2024 20:00:26 +0530 Subject: [PATCH 14/34] Fixed/Added Suggested Changes Signed-off-by: 11happy --- base/sysinfo.jl | 13 +++++-------- doc/src/base/base.md | 2 -- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 5342f27f4501f..551bdc2ee5496 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -32,7 +32,6 @@ export BINDIR, isunix, iswindows, isjsvm, - show, isexecutable, username, which @@ -236,6 +235,10 @@ describing a set of CPUs (which defaults to the return value of the [`Sys.cpu_in 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. + +!!! compat "Julia 1.11" +As of Julia 1.11, the `Sys.cpu_summary(io, cpu)` output is replicated by `show(io, "text/plain", cpu)` (which is called by e.g. +`display` for REPL output), so it need not be called directly. """ function cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info()) model = cpu[1].model @@ -641,14 +644,8 @@ function username() isempty(pw.username) && Base.uv_error("username", Base.UV_ENOENT) return pw.username end -""" - Sys.show(io::IO, ::MIME"text/plain", cpu::AbstractVector{CPUinfo}) -Print a summary of CPU information to the `io` stream (defaulting to [`stdout`](@ref)), -organizing and displaying aggregated data for CPUs with the same model, -for a given array of `CPUinfo` data structures. -""" -function show(io::IO,::MIME"text/plain",cpu::AbstractVector{CPUinfo}) +function show(io::IO, ::MIME"text/plain", cpu::AbstractVector{CPUinfo}) summary(io, cpu) println(io, ':') cpu_summary(io, cpu) diff --git a/doc/src/base/base.md b/doc/src/base/base.md index 26713294046e7..4f7d493777e98 100644 --- a/doc/src/base/base.md +++ b/doc/src/base/base.md @@ -358,7 +358,6 @@ Base.Sys.STDLIB Base.Sys.CPU_NAME Base.Sys.JIT Base.Sys.cpu_info -Base.Sys.cpu_summary Base.Sys.isunix Base.Sys.isapple Base.Sys.islinux @@ -378,7 +377,6 @@ Base.Sys.isjsvm Base.Sys.loadavg Base.Sys.isexecutable Base.Sys.username -Base.Sys.show Base.@static ``` From 0a3cf6f97154935505548044d0ee1ed23094c488 Mon Sep 17 00:00:00 2001 From: 11happy Date: Thu, 11 Jan 2024 20:04:40 +0530 Subject: [PATCH 15/34] Removed WhiteSpace Signed-off-by: 11happy --- base/sysinfo.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 551bdc2ee5496..ddfab7f6e5809 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -237,7 +237,7 @@ 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. !!! compat "Julia 1.11" -As of Julia 1.11, the `Sys.cpu_summary(io, cpu)` output is replicated by `show(io, "text/plain", cpu)` (which is called by e.g. +As of Julia 1.11, the `Sys.cpu_summary(io, cpu)` output is replicated by `show(io, "text/plain", cpu)` (which is called by e.g. `display` for REPL output), so it need not be called directly. """ function cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info()) From e11dfd98bc5c2f8f7b5334738ca80885a86e2540 Mon Sep 17 00:00:00 2001 From: 11happy Date: Thu, 11 Jan 2024 20:10:25 +0530 Subject: [PATCH 16/34] Added Space Signed-off-by: 11happy --- base/sysinfo.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index ddfab7f6e5809..495c3a009aa7f 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -237,7 +237,7 @@ 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. !!! compat "Julia 1.11" -As of Julia 1.11, the `Sys.cpu_summary(io, cpu)` output is replicated by `show(io, "text/plain", cpu)` (which is called by e.g. + As of Julia 1.11, the `Sys.cpu_summary(io, cpu)` output is replicated by `show(io, "text/plain", cpu)` (which is called by e.g. `display` for REPL output), so it need not be called directly. """ function cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info()) From eaf73a8e30162183ec97df0d481187b2da70be6a Mon Sep 17 00:00:00 2001 From: 11happy Date: Thu, 11 Jan 2024 20:16:52 +0530 Subject: [PATCH 17/34] Added Proper Indent Signed-off-by: 11happy --- base/sysinfo.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 495c3a009aa7f..8ec3cc6249a2a 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -237,8 +237,8 @@ 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. !!! compat "Julia 1.11" - As of Julia 1.11, the `Sys.cpu_summary(io, cpu)` output is replicated by `show(io, "text/plain", cpu)` (which is called by e.g. -`display` for REPL output), so it need not be called directly. + As of Julia 1.11, the `Sys.cpu_summary(io, cpu)` output is replicated by `show(io, "text/plain", cpu)` (which is called by e.g. + `display` for REPL output), so it need not be called directly. """ function cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info()) model = cpu[1].model From 3f6bec76c25318dfbeeecb31ccfffb24e3bfa48d Mon Sep 17 00:00:00 2001 From: Bhuminjay Soni <76656712+11happy@users.noreply.github.com> Date: Thu, 11 Jan 2024 23:44:27 +0530 Subject: [PATCH 18/34] Update base/sysinfo.jl Co-authored-by: Steven G. Johnson --- base/sysinfo.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 8ec3cc6249a2a..28ff1cbbe5e2e 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -118,7 +118,7 @@ global CPU_NAME::String A string representing the specific Just-In-Time (JIT) compiler being utilized in the current runtime. # Examples -Currently, this returns `"ORCJIT"` for the LLVM "ORC" ("On-Request Compilation") JIT library: +Currently, this equals `"ORCJIT"` for the LLVM "ORC" ("On-Request Compilation") JIT library: ```jldoctest julia> Sys.JIT "ORCJIT" From 88e6fae0f340a01ae2d49893cefdb02f7d233124 Mon Sep 17 00:00:00 2001 From: Bhuminjay Soni <76656712+11happy@users.noreply.github.com> Date: Thu, 11 Jan 2024 23:44:37 +0530 Subject: [PATCH 19/34] Update base/sysinfo.jl Co-authored-by: Steven G. Johnson --- base/sysinfo.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 28ff1cbbe5e2e..b52215d57454b 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -255,7 +255,7 @@ end """ Sys.cpu_info() -Return a vector of `CPUinfo` objects, where each object represent information about a CPU core. +Return a vector of `CPUinfo` objects, where each object represents information about a CPU core. This is displayed in a tabular format by the REPL, so most users will not need to access the `CPUinfo` data structures directly. From f35cb86ed4b0c692bf3e1b01263c7bd9b4c32f34 Mon Sep 17 00:00:00 2001 From: 11happy Date: Thu, 11 Jan 2024 23:49:43 +0530 Subject: [PATCH 20/34] suggested changed Signed-off-by: 11happy --- base/sysinfo.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 8ec3cc6249a2a..1827a717f2192 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -200,7 +200,7 @@ function _show_cpuinfo(io::IO, info::Sys.CPUinfo, header::Bool=true, prefix::Abs end end -show(io::IO, info::CPUinfo) = _show_cpuinfo(io, info, true, " ") +show(io::IO, ::MIME"text/plain", info::CPUinfo) = _show_cpuinfo(io, info, true, " ") function _cpu_summary(io::IO, cpu::AbstractVector{CPUinfo}, i, j) if j-i < 9 From 526ac1ec34c0072b706caf965316fdec042f395e Mon Sep 17 00:00:00 2001 From: 11happy Date: Fri, 12 Jan 2024 12:06:44 +0530 Subject: [PATCH 21/34] Public CPUinfo,Added Tests for show Signed-off-by: 11happy --- base/exports.jl | 1 + base/sysinfo.jl | 21 +++++++++++++-------- doc/src/base/base.md | 1 + test/sysinfo.jl | 11 +++++++++++ 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/base/exports.jl b/base/exports.jl index 92525b85c7635..f1b6a3ee75ff4 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -1088,6 +1088,7 @@ public Event, Fix1, Fix2, + CPUinfo, Generator, ImmutableDict, OneTo, diff --git a/base/sysinfo.jl b/base/sysinfo.jl index c4c88354bf2eb..a04e48ba07de3 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -165,6 +165,18 @@ mutable struct UV_cpu_info_t cpu_times!idle::UInt64 cpu_times!irq::UInt64 end +""" + Sys.CPUinfo + +The `CPUinfo` type is a mutable struct with the following fields: +- `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. +""" mutable struct CPUinfo model::String speed::Int32 @@ -260,14 +272,7 @@ This is displayed in a tabular format by the REPL, so most users will not need t data structures directly. 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: -- `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}}() diff --git a/doc/src/base/base.md b/doc/src/base/base.md index 4f7d493777e98..bcfca2d31938e 100644 --- a/doc/src/base/base.md +++ b/doc/src/base/base.md @@ -356,6 +356,7 @@ Base.EnvDict Base.ENV Base.Sys.STDLIB Base.Sys.CPU_NAME +Base.Sys.CPUinfo Base.Sys.JIT Base.Sys.cpu_info Base.Sys.isunix diff --git a/test/sysinfo.jl b/test/sysinfo.jl index 8864e3a48efc7..c624052fc4217 100644 --- a/test/sysinfo.jl +++ b/test/sysinfo.jl @@ -54,3 +54,14 @@ end @test !isempty(Sys.username()) end end + +@testset "show" begin + example_cpus = [Base.Sys.CPUinfo("Apple M1 Pro", 2400, 0x000000000d913b08, 0x0000000000000000, 0x0000000005f4243c, 0x00000000352a550a, 0x0000000000000000) + Base.Sys.CPUinfo("Apple M1 Pro", 2400, 0x000000000d9040c2, 0x0000000000000000, 0x0000000005d4768c, 0x00000000356b3d22, 0x0000000000000000) + Base.Sys.CPUinfo("Apple M1 Pro", 2400, 0x00000000026784da, 0x0000000000000000, 0x0000000000fda30e, 0x0000000046a731ea, 0x0000000000000000) + Base.Sys.CPUinfo("Apple M1 Pro", 2400, 0x00000000017726c0, 0x0000000000000000, 0x00000000009491de, 0x0000000048134f1e, 0x0000000000000000)] + + @test repr(example_cpus[1]) == "Base.Sys.CPUinfo(\"Apple M1 Pro\", 2400, 0x000000000d913b08, 0x0000000000000000, 0x0000000005f4243c, 0x00000000352a550a, 0x0000000000000000)" + @test repr("text/plain", example_cpus[1]) == "Apple M1 Pro: \n speed user nice sys idle irq\n 2400 MHz 2276216 s 0 s 998861 s 8919667 s 0 s" + @test repr("text/plain", example_cpus) == "4-element Vector{Base.Sys.CPUinfo}:\nApple M1 Pro: \n speed user nice sys idle irq\n#1 2400 MHz 2276216 s 0 s 998861 s 8919667 s 0 s\n#2 2400 MHz 2275576 s 0 s 978101 s 8962204 s 0 s\n#3 2400 MHz 403386 s 0 s 166224 s 11853624 s 0 s\n#4 2400 MHz 245859 s 0 s 97367 s 12092250 s 0 s\n" +end From 60fdb2fc9d89bdbbb75a9615830254b3cc15354e Mon Sep 17 00:00:00 2001 From: Bhuminjay Soni <76656712+11happy@users.noreply.github.com> Date: Sat, 13 Jan 2024 12:20:21 +0530 Subject: [PATCH 22/34] Update base/sysinfo.jl Co-authored-by: Steven G. Johnson --- base/sysinfo.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index a04e48ba07de3..92fb15344a38c 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -165,6 +165,7 @@ mutable struct UV_cpu_info_t cpu_times!idle::UInt64 cpu_times!irq::UInt64 end + """ Sys.CPUinfo From fc3d65275dda09c80ca9495bd930dbb75fc1cb61 Mon Sep 17 00:00:00 2001 From: Bhuminjay Soni <76656712+11happy@users.noreply.github.com> Date: Sat, 13 Jan 2024 12:20:59 +0530 Subject: [PATCH 23/34] Update test/sysinfo.jl Co-authored-by: Steven G. Johnson --- test/sysinfo.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sysinfo.jl b/test/sysinfo.jl index c624052fc4217..32c76bed88b0b 100644 --- a/test/sysinfo.jl +++ b/test/sysinfo.jl @@ -63,5 +63,5 @@ end @test repr(example_cpus[1]) == "Base.Sys.CPUinfo(\"Apple M1 Pro\", 2400, 0x000000000d913b08, 0x0000000000000000, 0x0000000005f4243c, 0x00000000352a550a, 0x0000000000000000)" @test repr("text/plain", example_cpus[1]) == "Apple M1 Pro: \n speed user nice sys idle irq\n 2400 MHz 2276216 s 0 s 998861 s 8919667 s 0 s" - @test repr("text/plain", example_cpus) == "4-element Vector{Base.Sys.CPUinfo}:\nApple M1 Pro: \n speed user nice sys idle irq\n#1 2400 MHz 2276216 s 0 s 998861 s 8919667 s 0 s\n#2 2400 MHz 2275576 s 0 s 978101 s 8962204 s 0 s\n#3 2400 MHz 403386 s 0 s 166224 s 11853624 s 0 s\n#4 2400 MHz 245859 s 0 s 97367 s 12092250 s 0 s\n" + @test Sys.cpu_summary(example_cpus) == "Apple M1 Pro: \n speed user nice sys idle irq\n#1 2400 MHz 2276216 s 0 s 998861 s 8919667 s 0 s\n#2 2400 MHz 2275576 s 0 s 978101 s 8962204 s 0 s\n#3 2400 MHz 403386 s 0 s 166224 s 11853624 s 0 s\n#4 2400 MHz 245859 s 0 s 97367 s 12092250 s 0 s\n" end From 4b3722afcf1881b54d38f45cdea0ed9a383ac568 Mon Sep 17 00:00:00 2001 From: 11happy Date: Sat, 13 Jan 2024 12:27:20 +0530 Subject: [PATCH 24/34] minor fixes Signed-off-by: 11happy --- base/exports.jl | 1 - base/sysinfo.jl | 14 ++++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/base/exports.jl b/base/exports.jl index f1b6a3ee75ff4..92525b85c7635 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -1088,7 +1088,6 @@ public Event, Fix1, Fix2, - CPUinfo, Generator, ImmutableDict, OneTo, diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 92fb15344a38c..8d285d022606e 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -171,12 +171,12 @@ end The `CPUinfo` type is a mutable struct with the following fields: - `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. +- `speed::Int32`: CPU speed. unit: MHz. +- `cpu_times!user::UInt64`: Time spent in user mode. CPU state shows CPU time used by user space processes. unit: second. +- `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.unit: second. +- `cpu_times!sys::UInt64`: Time spent in system mode. CPU state shows the amount of CPU time used by the kernel. unit: second. +- `cpu_times!idle::UInt64`: Time spent in idle mode. CPU state shows the CPU time that's not actively being used. unit: second. +- `cpu_times!irq::UInt64`: Time spent handling interrupts. CPU state shows the amount of time the CPU has been servicing hardware interrupts. unit: second. """ mutable struct CPUinfo model::String @@ -192,6 +192,8 @@ CPUinfo(info::UV_cpu_info_t) = CPUinfo(unsafe_string(info.model), info.speed, info.cpu_times!user, info.cpu_times!nice, info.cpu_times!sys, info.cpu_times!idle, info.cpu_times!irq) +public CPUinfo + function _show_cpuinfo(io::IO, info::Sys.CPUinfo, header::Bool=true, prefix::AbstractString=" ") tck = SC_CLK_TCK if header From 8f84372f167e038bd99192a368a7e6be0adf0526 Mon Sep 17 00:00:00 2001 From: 11happy Date: Sat, 13 Jan 2024 21:24:09 +0530 Subject: [PATCH 25/34] added cpu_summary method Signed-off-by: 11happy --- doc/src/base/base.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/src/base/base.md b/doc/src/base/base.md index bcfca2d31938e..c50557cf2aa9f 100644 --- a/doc/src/base/base.md +++ b/doc/src/base/base.md @@ -356,6 +356,7 @@ Base.EnvDict Base.ENV Base.Sys.STDLIB Base.Sys.CPU_NAME +Base.Sys.cpu_summary Base.Sys.CPUinfo Base.Sys.JIT Base.Sys.cpu_info From 8d92a49ae02a58f123b1b2c5ba76521fd8896ada Mon Sep 17 00:00:00 2001 From: 11happy Date: Mon, 15 Jan 2024 23:33:30 +0530 Subject: [PATCH 26/34] removed export of Sys.JIT,Sys.CPU_NAME,Sys.cpu_summary,Sys.cpu_info Signed-off-by: 11happy --- base/sysinfo.jl | 20 ++++++++++++++------ doc/src/base/base.md | 5 ----- test/sysinfo.jl | 8 +++++++- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 8d285d022606e..3846969d11a22 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -109,6 +109,8 @@ A string representing the name of CPU. For example, `Sys.CPU_NAME` might equal `"tigerlake"` on an [Intel Core "Tiger Lake" CPU](https://en.wikipedia.org/wiki/Tiger_Lake), or `"apple-m1"` on an [Apple M1 CPU](https://en.wikipedia.org/wiki/Apple_M1). + +Note: Included in the detailed system information via `versioninfo(verbose=true)`. """ global CPU_NAME::String @@ -123,6 +125,8 @@ Currently, this equals `"ORCJIT"` for the LLVM "ORC" ("On-Request Compilation") julia> Sys.JIT "ORCJIT" ``` + +Note: Included in the detailed system information via `versioninfo(verbose=true)`. """ global JIT::String @@ -171,12 +175,14 @@ end The `CPUinfo` type is a mutable struct with the following fields: - `model::String`: CPU model information. -- `speed::Int32`: CPU speed. unit: MHz. -- `cpu_times!user::UInt64`: Time spent in user mode. CPU state shows CPU time used by user space processes. unit: second. -- `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.unit: second. -- `cpu_times!sys::UInt64`: Time spent in system mode. CPU state shows the amount of CPU time used by the kernel. unit: second. -- `cpu_times!idle::UInt64`: Time spent in idle mode. CPU state shows the CPU time that's not actively being used. unit: second. -- `cpu_times!irq::UInt64`: Time spent handling interrupts. CPU state shows the amount of time the CPU has been servicing hardware interrupts. unit: second. +- `speed::Int32`: CPU speed (in MHz). +- `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. + +Note: Included in the detailed system information via `versioninfo(verbose=true)`. """ mutable struct CPUinfo model::String @@ -254,6 +260,8 @@ providing details such as average CPU speed and total time spent in different mo !!! compat "Julia 1.11" As of Julia 1.11, the `Sys.cpu_summary(io, cpu)` output is replicated by `show(io, "text/plain", cpu)` (which is called by e.g. `display` for REPL output), so it need not be called directly. + +Note: Included in the detailed system information via `versioninfo(verbose=true)`. """ function cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info()) model = cpu[1].model diff --git a/doc/src/base/base.md b/doc/src/base/base.md index c50557cf2aa9f..7172474b40b39 100644 --- a/doc/src/base/base.md +++ b/doc/src/base/base.md @@ -355,11 +355,6 @@ Base.@allocations Base.EnvDict Base.ENV Base.Sys.STDLIB -Base.Sys.CPU_NAME -Base.Sys.cpu_summary -Base.Sys.CPUinfo -Base.Sys.JIT -Base.Sys.cpu_info Base.Sys.isunix Base.Sys.isapple Base.Sys.islinux diff --git a/test/sysinfo.jl b/test/sysinfo.jl index 32c76bed88b0b..7b98ba34fa08b 100644 --- a/test/sysinfo.jl +++ b/test/sysinfo.jl @@ -55,6 +55,10 @@ end end end +@testset "Base.Sys docstrings" begin + @test isempty(Docs.undocumented_names(Sys)) +end + @testset "show" begin example_cpus = [Base.Sys.CPUinfo("Apple M1 Pro", 2400, 0x000000000d913b08, 0x0000000000000000, 0x0000000005f4243c, 0x00000000352a550a, 0x0000000000000000) Base.Sys.CPUinfo("Apple M1 Pro", 2400, 0x000000000d9040c2, 0x0000000000000000, 0x0000000005d4768c, 0x00000000356b3d22, 0x0000000000000000) @@ -63,5 +67,7 @@ end @test repr(example_cpus[1]) == "Base.Sys.CPUinfo(\"Apple M1 Pro\", 2400, 0x000000000d913b08, 0x0000000000000000, 0x0000000005f4243c, 0x00000000352a550a, 0x0000000000000000)" @test repr("text/plain", example_cpus[1]) == "Apple M1 Pro: \n speed user nice sys idle irq\n 2400 MHz 2276216 s 0 s 998861 s 8919667 s 0 s" - @test Sys.cpu_summary(example_cpus) == "Apple M1 Pro: \n speed user nice sys idle irq\n#1 2400 MHz 2276216 s 0 s 998861 s 8919667 s 0 s\n#2 2400 MHz 2275576 s 0 s 978101 s 8962204 s 0 s\n#3 2400 MHz 403386 s 0 s 166224 s 11853624 s 0 s\n#4 2400 MHz 245859 s 0 s 97367 s 12092250 s 0 s\n" + buf = IOBuffer() + Sys.cpu_summary(buf,example_cpus) + @test String(take!(buf)) == "Apple M1 Pro: \n speed user nice sys idle irq\n#1 2400 MHz 2276216 s 0 s 998861 s 8919667 s 0 s\n#2 2400 MHz 2275576 s 0 s 978101 s 8962204 s 0 s\n#3 2400 MHz 403386 s 0 s 166224 s 11853624 s 0 s\n#4 2400 MHz 245859 s 0 s 97367 s 12092250 s 0 s\n" end From 3309d862e59b2fc39e15b72c4fff491d1827d2ff Mon Sep 17 00:00:00 2001 From: Bhuminjay Soni <76656712+11happy@users.noreply.github.com> Date: Tue, 16 Jan 2024 19:54:13 +0530 Subject: [PATCH 27/34] Update base/sysinfo.jl Co-authored-by: Steven G. Johnson --- base/sysinfo.jl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 3846969d11a22..519c38406b9e5 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -257,10 +257,6 @@ describing a set of CPUs (which defaults to the return value of the [`Sys.cpu_in 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. -!!! compat "Julia 1.11" - As of Julia 1.11, the `Sys.cpu_summary(io, cpu)` output is replicated by `show(io, "text/plain", cpu)` (which is called by e.g. - `display` for REPL output), so it need not be called directly. - Note: Included in the detailed system information via `versioninfo(verbose=true)`. """ function cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info()) From 5e2cdbdcf52f3e72e942720deff61787190607b3 Mon Sep 17 00:00:00 2001 From: Bhuminjay Soni <76656712+11happy@users.noreply.github.com> Date: Tue, 16 Jan 2024 19:54:43 +0530 Subject: [PATCH 28/34] Update test/sysinfo.jl Co-authored-by: Steven G. Johnson --- test/sysinfo.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/sysinfo.jl b/test/sysinfo.jl index 7b98ba34fa08b..3efdb85eda9ee 100644 --- a/test/sysinfo.jl +++ b/test/sysinfo.jl @@ -67,7 +67,7 @@ end @test repr(example_cpus[1]) == "Base.Sys.CPUinfo(\"Apple M1 Pro\", 2400, 0x000000000d913b08, 0x0000000000000000, 0x0000000005f4243c, 0x00000000352a550a, 0x0000000000000000)" @test repr("text/plain", example_cpus[1]) == "Apple M1 Pro: \n speed user nice sys idle irq\n 2400 MHz 2276216 s 0 s 998861 s 8919667 s 0 s" - buf = IOBuffer() - Sys.cpu_summary(buf,example_cpus) - @test String(take!(buf)) == "Apple M1 Pro: \n speed user nice sys idle irq\n#1 2400 MHz 2276216 s 0 s 998861 s 8919667 s 0 s\n#2 2400 MHz 2275576 s 0 s 978101 s 8962204 s 0 s\n#3 2400 MHz 403386 s 0 s 166224 s 11853624 s 0 s\n#4 2400 MHz 245859 s 0 s 97367 s 12092250 s 0 s\n" + Sys.SC_CLK_TCK, save_SC_CLK_TCK = 100, Sys.SC_CLK_TCK + @test sprint(Sys.cpu_summary, example_cpus) == "Apple M1 Pro: \n speed user nice sys idle irq\n#1 2400 MHz 2276216 s 0 s 998861 s 8919667 s 0 s\n#2 2400 MHz 2275576 s 0 s 978101 s 8962204 s 0 s\n#3 2400 MHz 403386 s 0 s 166224 s 11853624 s 0 s\n#4 2400 MHz 245859 s 0 s 97367 s 12092250 s 0 s\n" + Sys.SC_CLK_TCK = save_SC_CLK_TCK end From 06f5a4c081c616d5b5b8f19e5d383334b24dc7af Mon Sep 17 00:00:00 2001 From: Bhuminjay Soni <76656712+11happy@users.noreply.github.com> Date: Tue, 16 Jan 2024 19:55:18 +0530 Subject: [PATCH 29/34] Update base/sysinfo.jl Co-authored-by: Steven G. Johnson --- base/sysinfo.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 519c38406b9e5..9c094b91bfdd5 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -182,6 +182,9 @@ The `CPUinfo` type is a mutable struct with the following fields: - `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. +The times are in units of `1/Sys.SC_CLK_TCK` seconds if `Sys.SC_CLK_TCK > 0`; otherwise they are in +unknown units. + Note: Included in the detailed system information via `versioninfo(verbose=true)`. """ mutable struct CPUinfo From 6cf7d26bf9b402260545d3224baac9a81e510434 Mon Sep 17 00:00:00 2001 From: Bhuminjay Soni <76656712+11happy@users.noreply.github.com> Date: Tue, 16 Jan 2024 19:55:35 +0530 Subject: [PATCH 30/34] Update base/sysinfo.jl Co-authored-by: Steven G. Johnson --- base/sysinfo.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 9c094b91bfdd5..b97ee725c7400 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -278,7 +278,9 @@ end Sys.cpu_info() Return a vector of `CPUinfo` objects, where each object represents information about a CPU core. -This is displayed in a tabular format by the REPL, so most users will not need to access the `CPUinfo` + +This is pretty-printed in a tabular format by `Sys.cpu_summary`, which is included in the output +of `versioninfo(verbose=true)`, so most users will not need to access the `CPUinfo` data structures directly. 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. From 718740e13dbceacc8262a1dd63b841e71857477e Mon Sep 17 00:00:00 2001 From: Bhuminjay Soni <76656712+11happy@users.noreply.github.com> Date: Tue, 16 Jan 2024 19:55:56 +0530 Subject: [PATCH 31/34] Update base/sysinfo.jl Co-authored-by: Steven G. Johnson --- base/sysinfo.jl | 6 ------ 1 file changed, 6 deletions(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index b97ee725c7400..ab33e9b0d9d3a 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -662,10 +662,4 @@ function username() return pw.username end -function show(io::IO, ::MIME"text/plain", cpu::AbstractVector{CPUinfo}) - summary(io, cpu) - println(io, ':') - cpu_summary(io, cpu) -end - end # module Sys From adbf6b08fd9812ba5e36731fa8d414967667c8b8 Mon Sep 17 00:00:00 2001 From: Bhuminjay Soni <76656712+11happy@users.noreply.github.com> Date: Tue, 16 Jan 2024 21:38:09 +0530 Subject: [PATCH 32/34] Update base/sysinfo.jl Co-authored-by: Steven G. Johnson --- base/sysinfo.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index ab33e9b0d9d3a..c1017ce5da686 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -98,6 +98,14 @@ Standard word size on the current machine, in bits. """ const WORD_SIZE = Core.sizeof(Int) * 8 +""" + Sys.SC_CLK_TCK: + +The number of system "clock ticks" per second, corresponding to `sysconf(_SC_CLK_TCK)` on +POSIX systems, or `0` if it is unknown. + +CPU times, e.g. as returned by `Sys.cpu_info()`, are in units of ticks, i.e. units of `1 / Sys.SC_CLK_TCK` seconds if `Sys.SC_CLK_TCK > 0`. +""" global SC_CLK_TCK::Clong """ From a391a4e18f57b0dd68125532672288bf7fb20f26 Mon Sep 17 00:00:00 2001 From: 11happy Date: Tue, 16 Jan 2024 21:47:35 +0530 Subject: [PATCH 33/34] Formatted the code Signed-off-by: 11happy --- base/sysinfo.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index c1017ce5da686..5cb37721c138c 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -100,7 +100,7 @@ const WORD_SIZE = Core.sizeof(Int) * 8 """ Sys.SC_CLK_TCK: - + The number of system "clock ticks" per second, corresponding to `sysconf(_SC_CLK_TCK)` on POSIX systems, or `0` if it is unknown. From d4e3a3d52ad01ae6e3dd2f77cd8b592d6f3340a6 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Tue, 16 Jan 2024 20:26:47 -0500 Subject: [PATCH 34/34] Update test/sysinfo.jl --- test/sysinfo.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sysinfo.jl b/test/sysinfo.jl index 3efdb85eda9ee..f02d8ffe36091 100644 --- a/test/sysinfo.jl +++ b/test/sysinfo.jl @@ -65,9 +65,9 @@ end Base.Sys.CPUinfo("Apple M1 Pro", 2400, 0x00000000026784da, 0x0000000000000000, 0x0000000000fda30e, 0x0000000046a731ea, 0x0000000000000000) Base.Sys.CPUinfo("Apple M1 Pro", 2400, 0x00000000017726c0, 0x0000000000000000, 0x00000000009491de, 0x0000000048134f1e, 0x0000000000000000)] + Sys.SC_CLK_TCK, save_SC_CLK_TCK = 100, Sys.SC_CLK_TCK # use platform-independent tick units @test repr(example_cpus[1]) == "Base.Sys.CPUinfo(\"Apple M1 Pro\", 2400, 0x000000000d913b08, 0x0000000000000000, 0x0000000005f4243c, 0x00000000352a550a, 0x0000000000000000)" @test repr("text/plain", example_cpus[1]) == "Apple M1 Pro: \n speed user nice sys idle irq\n 2400 MHz 2276216 s 0 s 998861 s 8919667 s 0 s" - Sys.SC_CLK_TCK, save_SC_CLK_TCK = 100, Sys.SC_CLK_TCK @test sprint(Sys.cpu_summary, example_cpus) == "Apple M1 Pro: \n speed user nice sys idle irq\n#1 2400 MHz 2276216 s 0 s 998861 s 8919667 s 0 s\n#2 2400 MHz 2275576 s 0 s 978101 s 8962204 s 0 s\n#3 2400 MHz 403386 s 0 s 166224 s 11853624 s 0 s\n#4 2400 MHz 245859 s 0 s 97367 s 12092250 s 0 s\n" Sys.SC_CLK_TCK = save_SC_CLK_TCK end