MachineInfo/NumCPUs.pm untested

filter: Statementstmt 0.0% 0 / 23 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 32 CC 2 SCAR 11.5
CC
2
Cov
0%
get
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.1
1 =head1 NAME
2  
3 Probe::MachineInfo::NumCPUs - Number of CPUs
4  
5 =head1 SYNOPSIS
6  
7 blah
8  
9 =head1 DESCRIPTION
10  
11 blah
12  
13 =head1 PUBLIC INTERFACE
14  
15 =cut
16  
17 package Probe::MachineInfo::NumCPUs;
18  
19  
20 # pragmata
21 use base qw(Probe::MachineInfo::Metric);
22 use strict;
23 use warnings;
24  
25  
26 # Standard Perl Library and CPAN modules
27 use English;
28 use Unix::Processors;
29  
30 #
31 # CLASS ATTRIBUTES
32 #
33  
34 #
35 # CONSTRUCTOR
36 #
37  
38  
39 =head2 get
40  
41 get()
42  
43 Uses Unix::Processors to return the number of processors on the machine. If
44 possible it returns the number of physical processors. If this is not possible
45 on the particular operating system then returns the number of cpus online.
46  
47 =cut
48  
49 sub get {
50 my ($self) = @_;
51  
52 my $proc = Unix::Processors->new();
53 my $num;
54 eval {
55 $num = $proc->max_physical;
56 };
57 if($@) {
58 $num = $proc->max_online;
59 }
60 return $num;
61 }
62  
63 1;
64  
65 =head1 AUTHOR
66  
67 Sagar R. Shah
68  
69 =cut