File Coverage

blib/lib/Sys/Simple.pm
Criterion Covered Total %
statement 10 10 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 15 15 100.0


line stmt bran cond sub pod time code
1             package Sys::Simple;
2              
3 1     1   509 use strict;
  1         1  
  1         26  
4 1     1   3 use warnings;
  1         1  
  1         59  
5              
6             require Exporter;
7             our @ISA = qw/Exporter/;
8             our @EXPORT_OK = qw/cpu_usage/;
9              
10             our $VERSION = 0.001;
11              
12 1     1   304 use Sys::Simple::CPU::Linux;
  1         2  
  1         51  
13              
14             # Only works on linux for now
15              
16 2     2 1 800 sub cpu_usage{ return Sys::Simple::CPU::Linux::cpu_usage( @_ ); }
17              
18             1;
19              
20             # ABSTRACT: Sys Simple, functional system information, made simple
21              
22             =head1 NAME
23              
24             Sys::Simple is a set of functions and perl modules that retrieve information
25             about the local system. The goal is to have light and simple functions, that
26             has a simple scopped answer.
27              
28             =head1 VERSION
29              
30             version 0.001
31              
32             =head1 SYNOPSIS
33              
34             use Sys::Simple qw/ list of functions/;
35              
36             function();
37              
38             OR
39              
40             you can use a given function directly using the full namespace:
41              
42             use Sys::Simple::CPU::Linux;
43              
44             Sys::Simple::CPU::Linux::cpu_usage();
45              
46             =head1 EXPORTS
47              
48             None of the functions are exported by default
49              
50             =head2 cpu_usage
51              
52             Returns the amount of the cpu being used on the machine. If the
53             machine have more than one cpu or cores, it will count all processing
54             power as one and give the percentage used from the pool. By example
55             a given machine with 4 cpus with three of them idle and one at full use
56             will return 0.25. To have the total percentage you must multiply the
57             value by 100;
58              
59             The way it calculates use a wait of 10 miliseconds, but if more time
60             is necessary you can pass a numeric argument and this will multiply the
61             10 miliseconds used as interval to calculate the cpu_usage.
62              
63             There is other modules all over CPAN that does almost the same, this one
64             is different because really does not create an object, or requires setup,
65             or whatever, call it and return the usage.
66              
67              
68             =head1 SOURCE CODE
69              
70             Github: https://github.com/fredericorecsky/Sys-Simple
71              
72             =head1 AUTHOR
73              
74             Frederico Recsky
75              
76             This program is free software; you can redistribute it
77             and/or modify it under the same terms as Perl itself.
78              
79             =cut