Sys::I...e::CPU(3pm)
π NAME π
okay bestie, so this module is Sys::Info::Device::CPU β like, the module that tells you everything about your CPU. and also, the manual name is Sys::I...e::CPU(3pm) and it lives in the User Contributed Perl Documentation, so jot that down π«Ά
β¨ VERSION β¨
version 0.7810 β yes she's been around a minute, she's vintage, she's iconic, we love a legacy queen π
πΈ SYNOPSIS πΈ
use Sys::Info;
use Sys::Info::Constants qw( :device_cpu );
my $info = Sys::Info->new;
my $cpu = $info->device( CPU => %options );
Example:
printf "CPU: %s\n", scalar($cpu->identify) || 'N/A';
printf "CPU speed is %s MHz\n", $cpu->speed || 'N/A';
printf "There are %d CPUs\n" , $cpu->count || 1;
printf "CPU load: %s\n" , $cpu->load || 0;
like look at her go π four whole lines of printf and she's already telling you your CPU's whole life story.
π¦ DESCRIPTION π¦
She collects and returns information about the Central Processing Unit (CPU) on the host machine. That's the whole gig. That's the assignment.
But fr fr, hear me out: some platforms can limit the available information under some user accounts π and that will affect the accessible amount of data. When that happens, some methods will just... not return anything usable. Not her fault, blame the platform. no cap.
π NAME π
(okay so the NAME section showed up TWICE in this manpage and honestly? she said "I contain multitudes" and I respect it. here's round two β)
Sys::Info::Device::CPU β CPU information. periodt.
π₯ METHODS π₯
π new π
Accepts parameters in key => value format. Very demure, very mindful, very key-value. π
π« cache
If it has a true value, the internal cache gets enabled (slay). The cache timeout can be controlled via the cache_timeout parameter.
So here's the tea π β on some platforms, some methods can take a long time to complete (i.e.: WMI access on the Windows platform). If cache is enabled, all gathered data will be saved in an internal in-memory cache and, the related method will serve from cache until the cache expires. Protecting your time like the main character she is.
Cache only has a meaning if you call the related method continuously (in a loop, under persistent environments like GUI, mod_perl, PerlEx, etc.). It will not have any effect if you are calling it only once. One-off call? Cache said "I don't know her." π
π« cache_timeout
Must be used together with the cache parameter. If cache is enabled, and this is not set, it will take the default value: 10.
Timeout value is in seconds. so basically "hold that thought for ten seconds and then we re-evaluate." β³
π identify π
If called in a list context β returns an AoH filled with CPU metadata. If called in a scalar context β returns the name of the CPU (if CPU is multi-core or there are multiple CPUs, it'll also include the number of CPUs). She's adaptable. She contains range. π
Returns undef upon failure. (a tragedy, but she said so herself.)
π speed π
Returns the CPU clock speed in MHz if successful. Returns undef otherwise. that's it, that's the method, she's short and she knows her worth π
π count π
Returns the number of CPUs (or number of total cores). So when you need the headcount for the function, this is her. π§
π bitness π
If successful, returns the bitness ( 32 or 64 ) of the CPU. Returns false otherwise. Are we a 32 girlie or a 64 girlie, we're about to find out πΈ
π load [, LEVEL] π
Returns the CPU load percentage if successful. Returns undef otherwise.
The average CPU load average in the last minute. If you pass a level argument, it'll return the related CPU load. Choose your own adventure, bestie β¨
use Sys::Info::Constants qw( :device_cpu );
printf "CPU Load: %s\n", $cpu->load(DCPU_LOAD_LAST_01);
Load level constants:
LEVEL MEANING
----------------- -------------------------------
DCPU_LOAD_LAST_01 CPU Load in the last 1 minute
DCPU_LOAD_LAST_05 CPU Load in the last 5 minutes
DCPU_LOAD_LAST_10 CPU Load in the last 10 minutes
LEVEL defaults to DCPU_LOAD_LAST_01.
β οΈ okay important!! Using this method under Windows is not recommended since, the WMI interface will possibly take at least 2 seconds to complete the request. two whole seconds of your life. she warned you. π
π hyper_threading π
π ht π
(both names, same energy, she answers to either π«Ά)
Returns the number of threads if hyper threading is supported, returns false otherwise. threads!! plural!! the multitasking icon behavior π¦
π SEE ALSO π
Sys::InfoSys::Info::OSSys::Info::Device
her friends! her little crew! go say hi to them too π
π AUTHOR π
Burak Gursoy β the author, the architect, the moment. we stan π«Ά
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2006 by Burak Gursoy.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
free software!! go forth and redistribute, bestie, legally π
and that's a wrap on Sys::I...e::CPU(3pm) from the User Contributed Perl Documentation, page generated 2025-10-07 with perl v5.40.1 π
β¨ bye bestie, go check your CPU, she's been waiting π
π¦ where this page comes from
- ubuntu resolute: libsys-info-base-perl 0.7810-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libsys-info-base-perl 0.7810-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms