GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Sys::Info::Device::CPU(3) User Contributed Perl Documentation Sys::Info::Device::CPU(3)

Sys::Info::Device::CPU

version 0.7807

   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;

Collects and returns information about the Central Processing Unit (CPU) on the host machine.

Some platforms can limit the available information under some user accounts and this will affect the accessible amount of data. When this happens, some methods will not return anything usable.

Sys::Info::Device::CPU - CPU information.

Acceps parameters in "key => value" format.

cache

If has a true value, internal cache will be enabled. Cache timeout can be controlled via "cache_timeout" parameter.

On some platforms, some methods can take a long time to be completed (i.e.: WMI access on 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.

Cache only has a meaning, if you call the related method continiously (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.

cache_timeout

Must be used together with "cache" parameter. If cache is enabled, and this is not set, it will take the default value: 10.

Timeout value is in seconds.

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).

Returns "undef" upon failure.

Returns the CPU clock speed in MHz if successful. Returns "undef" otherwise.

Returns the number of CPUs (or number of total cores).

If successful, returns the bitness ( 32 or 64 ) of the CPU. Returns false otherwise.

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.

    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".

Using this method under Windows is not recommended since, the "WMI" interface will possibly take at least 2 seconds to complete the request.

Returns the number of threads if hyper threading is supported, returns false otherwise.

Sys::Info, Sys::Info::OS, Sys::Info::Device.

Burak Gursoy <burak@cpan.org>

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.

2018-12-25 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.