Dpkg/SysInfo.pm

filter: Statementstmt 53.8% 7 / 13 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod 0.0% 0 / 1 totaltotal 42.8% 9 / 21 CC 3 SCAR 20.3
CC
3
Cov
41%
get_num_processors
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.6
« Dpkg/Color.pm ↑ Summary Dpkg/Interface/Storable.pm »
1 # Copyright © 2014-2025 Guillem Jover <guillem@debian.org>
2 #
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
15  
16 =encoding utf8
17  
18 =head1 NAME
19  
20 Dpkg::SysInfo - system information support
21  
22 =head1 DESCRIPTION
23  
24 This module implements system information functions used to gather data
25 about the current system.
26  
27 B<Note>: This is a private module, its API can change at any time.
28  
29 =cut
30  
31 package Dpkg::SysInfo 0.01;
32  
33 1 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 1 our @EXPORT_OK = qw(
36 get_num_processors
37 );
38  
39 1 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 0 ▶sub get_num_processors()
Subroutine get_num_processors: not called CC=3 SCAR=24.8
Pod undocumented
42 {
43 0 my $nproc;
44  
45 # Most Unices.
46 0 $nproc = qx(getconf _NPROCESSORS_ONLN 2>/dev/null);
47  
48 # Fallback for at least Irix.
49 0 ▶ $nproc = qx(getconf _NPROC_ONLN 2>/dev/null) if $?;
Branch: 1 branch
BranchTrueFalseTotal
if $? 0 0 0
50  
51 # Fallback to serial execution if cannot infer the number of online
52 # processors.
53 0 ▶ $nproc = '1' if $?;
Branch: 1 branch
BranchTrueFalseTotal
if $? 0 0 0
54  
55 0 chomp $nproc;
56  
57 0 return $nproc;
58 }
59  
60 =head1 CHANGES
61  
62 =head2 Version 0.xx
63  
64 This is a private module.
65  
66 =cut
67  
68 1 1;
« Dpkg/Color.pm ↑ Summary Dpkg/Interface/Storable.pm »