Filename | /home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Devel/Platform/Info.pm |
Statements | Executed 9 statements in 232µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 10µs | 20µs | BEGIN@3 | Devel::Platform::Info::
1 | 1 | 1 | 8µs | 12µs | BEGIN@4 | Devel::Platform::Info::
1 | 1 | 1 | 8µs | 30µs | BEGIN@6 | Devel::Platform::Info::
0 | 0 | 0 | 0s | 0s | get_info | Devel::Platform::Info::
0 | 0 | 0 | 0s | 0s | new | Devel::Platform::Info::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Devel::Platform::Info; | ||||
2 | |||||
3 | 2 | 19µs | 2 | 30µs | # spent 20µs (10+10) within Devel::Platform::Info::BEGIN@3 which was called:
# once (10µs+10µs) by Benchmark::Perl::Formance::BEGIN@15 at line 3 # spent 20µs making 1 call to Devel::Platform::Info::BEGIN@3
# spent 10µs making 1 call to strict::import |
4 | 2 | 19µs | 2 | 17µs | # spent 12µs (8+5) within Devel::Platform::Info::BEGIN@4 which was called:
# once (8µs+5µs) by Benchmark::Perl::Formance::BEGIN@15 at line 4 # spent 12µs making 1 call to Devel::Platform::Info::BEGIN@4
# spent 4µs making 1 call to warnings::import |
5 | |||||
6 | 2 | 172µs | 2 | 52µs | # spent 30µs (8+22) within Devel::Platform::Info::BEGIN@6 which was called:
# once (8µs+22µs) by Benchmark::Perl::Formance::BEGIN@15 at line 6 # spent 30µs making 1 call to Devel::Platform::Info::BEGIN@6
# spent 22µs making 1 call to vars::import |
7 | 1 | 600ns | $VERSION = '0.11'; | ||
8 | |||||
9 | #---------------------------------------------------------------------------- | ||||
10 | |||||
11 | 1 | 15µs | my %map = ( | ||
12 | # Unix (and like) family OSes | ||||
13 | 'freebsd' => 'BSD', | ||||
14 | 'openbsd' => 'BSD', | ||||
15 | 'netbsd' => 'BSD', | ||||
16 | 'mirbsd' => 'BSD', | ||||
17 | 'dragonfly' => 'BSD', | ||||
18 | 'midnightbsd' => 'BSD', | ||||
19 | |||||
20 | 'irix' => 'Irix', | ||||
21 | |||||
22 | 'linux' => 'Linux', | ||||
23 | 'aix' => 'Linux', | ||||
24 | 'bsdos' => 'Linux', | ||||
25 | 'dgux' => 'Linux', | ||||
26 | 'dynixptx' => 'Linux', | ||||
27 | 'hpux' => 'Linux', | ||||
28 | 'dec_osf' => 'Linux', | ||||
29 | 'svr4' => 'Linux', | ||||
30 | 'unicos' => 'Linux', | ||||
31 | 'unicosmk' => 'Linux', | ||||
32 | 'ultrix' => 'Linux', | ||||
33 | |||||
34 | 'sco_sv' => 'SCO', | ||||
35 | 'sco3' => 'SCO', | ||||
36 | 'sco' => 'SCO', | ||||
37 | |||||
38 | 'solaris' => 'Solaris', | ||||
39 | 'sunos' => 'Solaris', | ||||
40 | |||||
41 | # Windows family OSes | ||||
42 | 'dos' => 'Win32', | ||||
43 | 'os2' => 'Win32', | ||||
44 | 'mswin32' => 'Win32', | ||||
45 | 'netware' => 'Win32', | ||||
46 | 'cygwin' => 'Win32', | ||||
47 | |||||
48 | # Mac family OSes | ||||
49 | 'macos' => 'Mac', | ||||
50 | 'rhapsody' => 'Mac', | ||||
51 | 'darwin' => 'Mac', | ||||
52 | |||||
53 | # Other OSes | ||||
54 | 'vms' => 'Linux', | ||||
55 | 'vos' => 'Linux', | ||||
56 | 'os390' => 'Linux', | ||||
57 | 'vmesa' => 'Linux', | ||||
58 | 'riscos' => 'Linux', | ||||
59 | 'amigaos' => 'Linux', | ||||
60 | 'beos' => 'Linux', | ||||
61 | 'machten' => 'Linux', | ||||
62 | 'mpeix' => 'Linux', | ||||
63 | ); | ||||
64 | |||||
65 | #---------------------------------------------------------------------------- | ||||
66 | |||||
67 | sub new { | ||||
68 | my ($class) = @_; | ||||
69 | my $self = {}; | ||||
70 | bless $self, $class; | ||||
71 | return $self; | ||||
72 | } | ||||
73 | |||||
74 | sub get_info { | ||||
75 | my $self = shift; | ||||
76 | my $data; | ||||
77 | |||||
78 | my $plugin = $map{ lc $^O } || 'Linux'; | ||||
79 | |||||
80 | my $driver = 'Devel::Platform::Info::' . $plugin; | ||||
81 | my $require = "$driver.pm"; | ||||
82 | $require =~ s!::!/!g; | ||||
83 | |||||
84 | eval { | ||||
85 | require $require; | ||||
86 | $self->{driver} = $driver->new(); | ||||
87 | $data = $self->{driver}->get_info(); | ||||
88 | }; | ||||
89 | |||||
90 | return if($@); | ||||
91 | return $data; | ||||
92 | } | ||||
93 | |||||
94 | 1 | 6µs | 1; | ||
95 | |||||
96 | __END__ |