1Sys::Info::Device::CPU(U3s)er Contributed Perl DocumentatSiyosn::Info::Device::CPU(3)
2
3
4

NAME

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

SYNOPSIS

9          use Sys::Info;
10          use Sys::Info::Constants qw( :device_cpu );
11          my $info = Sys::Info->new;
12          my $cpu  = $info->device( CPU => %options );
13
14       Example:
15
16          printf "CPU: %s\n", scalar($cpu->identify)  || 'N/A';
17          printf "CPU speed is %s MHz\n", $cpu->speed || 'N/A';
18          printf "There are %d CPUs\n"  , $cpu->count || 1;
19          printf "CPU load: %s\n"       , $cpu->load  || 0;
20

DESCRIPTION

22       This document describes version 0.7804 of "Sys::Info::Device::CPU"
23       released on "21 January 2015".
24
25       Collects and returns information about the Central Processing Unit
26       (CPU) on the host machine.
27
28       Some platforms can limit the available information under some user
29       accounts and this will affect the accessible amount of data. When this
30       happens, some methods will not return anything usable.
31

METHODS

33   new
34       Acceps parameters in "key => value" format.
35
36       cache
37
38       If has a true value, internal cache will be enabled.  Cache timeout can
39       be controlled via "cache_timeout" parameter.
40
41       On some platforms, some methods can take a long time to be completed
42       (i.e.: WMI access on Windows platform).  If cache is enabled, all
43       gathered data will be saved in an internal in-memory cache and, the
44       related method will serve from cache until the cache expires.
45
46       Cache only has a meaning, if you call the related method continiously
47       (in a loop, under persistent environments like GUI, mod_perl, PerlEx,
48       etc.). It will not have any effect if you are calling it only once.
49
50       cache_timeout
51
52       Must be used together with "cache" parameter. If cache is enabled, and
53       this is not set, it will take the default value: 10.
54
55       Timeout value is in seconds.
56
57   identify
58       If called in a list context; returns an AoH filled with CPU metadata.
59       If called in a scalar context, returns the name of the CPU (if CPU is
60       multi-core or there are multiple CPUs, it'll also include the number of
61       CPUs).
62
63       Returns "undef" upon failure.
64
65   speed
66       Returns the CPU clock speed in MHz if successful.  Returns "undef"
67       otherwise.
68
69   count
70       Returns the number of CPUs (or number of total cores).
71
72   bitness
73       If successful, returns the bitness ( 32 or 64 ) of the CPU. Returns
74       false otherwise.
75
76   load [, LEVEL]
77       Returns the CPU load percentage if successful.  Returns "undef"
78       otherwise.
79
80       The average CPU load average in the last minute. If you pass a level
81       argument, it'll return the related CPU load.
82
83           use Sys::Info::Constants qw( :device_cpu );
84           printf "CPU Load: %s\n", $cpu->load(DCPU_LOAD_LAST_01);
85
86       Load level constants:
87
88           LEVEL               MEANING
89           -----------------   -------------------------------
90           DCPU_LOAD_LAST_01   CPU Load in the last  1 minute
91           DCPU_LOAD_LAST_05   CPU Load in the last  5 minutes
92           DCPU_LOAD_LAST_10   CPU Load in the last 10 minutes
93
94       "LEVEL" defaults to "DCPU_LOAD_LAST_01".
95
96       Using this method under Windows is not recommended since, the "WMI"
97       interface will possibly take at least 2 seconds to complete the
98       request.
99
100   hyper_threading
101   ht
102       Returns the number of threads if hyper threading is supported, returns
103       false otherwise.
104

SEE ALSO

106       Sys::Info, Sys::Info::OS, Sys::Info::Device.
107

AUTHOR

109       Burak Gursoy <burak@cpan.org>.
110
112       Copyright 2006 - 2015 Burak Gursoy. All rights reserved.
113

LICENSE

115       This library is free software; you can redistribute it and/or modify it
116       under the same terms as Perl itself, either Perl version 5.16.2 or, at
117       your option, any later version of Perl 5 you may have available.
118
119
120
121perl v5.28.0                      2018-07-15         Sys::Info::Device::CPU(3)
Impressum