1Sys::Info::Device::CPU(U3s)er Contributed Perl DocumentatSiyosn::Info::Device::CPU(3)
2
3
4
6 Sys::Info::Device::CPU
7
9 version 0.7807
10
12 use Sys::Info;
13 use Sys::Info::Constants qw( :device_cpu );
14 my $info = Sys::Info->new;
15 my $cpu = $info->device( CPU => %options );
16
17 Example:
18
19 printf "CPU: %s\n", scalar($cpu->identify) || 'N/A';
20 printf "CPU speed is %s MHz\n", $cpu->speed || 'N/A';
21 printf "There are %d CPUs\n" , $cpu->count || 1;
22 printf "CPU load: %s\n" , $cpu->load || 0;
23
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
33 Sys::Info::Device::CPU - CPU information.
34
36 new
37 Acceps parameters in "key => value" format.
38
39 cache
40
41 If has a true value, internal cache will be enabled. Cache timeout can
42 be controlled via "cache_timeout" parameter.
43
44 On some platforms, some methods can take a long time to be completed
45 (i.e.: WMI access on Windows platform). If cache is enabled, all
46 gathered data will be saved in an internal in-memory cache and, the
47 related method will serve from cache until the cache expires.
48
49 Cache only has a meaning, if you call the related method continiously
50 (in a loop, under persistent environments like GUI, mod_perl, PerlEx,
51 etc.). It will not have any effect if you are calling it only once.
52
53 cache_timeout
54
55 Must be used together with "cache" parameter. If cache is enabled, and
56 this is not set, it will take the default value: 10.
57
58 Timeout value is in seconds.
59
60 identify
61 If called in a list context; returns an AoH filled with CPU metadata.
62 If called in a scalar context, returns the name of the CPU (if CPU is
63 multi-core or there are multiple CPUs, it'll also include the number of
64 CPUs).
65
66 Returns "undef" upon failure.
67
68 speed
69 Returns the CPU clock speed in MHz if successful. Returns "undef"
70 otherwise.
71
72 count
73 Returns the number of CPUs (or number of total cores).
74
75 bitness
76 If successful, returns the bitness ( 32 or 64 ) of the CPU. Returns
77 false otherwise.
78
79 load [, LEVEL]
80 Returns the CPU load percentage if successful. Returns "undef"
81 otherwise.
82
83 The average CPU load average in the last minute. If you pass a level
84 argument, it'll return the related CPU load.
85
86 use Sys::Info::Constants qw( :device_cpu );
87 printf "CPU Load: %s\n", $cpu->load(DCPU_LOAD_LAST_01);
88
89 Load level constants:
90
91 LEVEL MEANING
92 ----------------- -------------------------------
93 DCPU_LOAD_LAST_01 CPU Load in the last 1 minute
94 DCPU_LOAD_LAST_05 CPU Load in the last 5 minutes
95 DCPU_LOAD_LAST_10 CPU Load in the last 10 minutes
96
97 "LEVEL" defaults to "DCPU_LOAD_LAST_01".
98
99 Using this method under Windows is not recommended since, the "WMI"
100 interface will possibly take at least 2 seconds to complete the
101 request.
102
103 hyper_threading
104 ht
105 Returns the number of threads if hyper threading is supported, returns
106 false otherwise.
107
109 Sys::Info, Sys::Info::OS, Sys::Info::Device.
110
112 Burak Gursoy <burak@cpan.org>
113
115 This software is copyright (c) 2006 by Burak Gursoy.
116
117 This is free software; you can redistribute it and/or modify it under
118 the same terms as the Perl 5 programming language system itself.
119
120
121
122perl v5.30.1 2020-01-30 Sys::Info::Device::CPU(3)