| 1 | # Declare our package | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | package POE::Devel::Benchmarker::Utils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # Initialize our version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use vars qw( $VERSION ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | $VERSION = '0.05'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # set ourself up for exporting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use base qw( Exporter ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | our @EXPORT_OK = qw( poeloop2load load2poeloop loop2realversion beautify_times knownloops generateTestfile | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | currentMetrics currentTestVersion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # returns the current test output version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub currentTestVersion { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
currentTestVersion: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | return '1'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # returns the list of current metrics | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | sub currentMetrics { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
currentMetrics: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | return [ qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | startups | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | alarms alarm_adds alarm_clears | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | dispatches posts single_posts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | session_creates session_destroys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | select_read_MYFH select_write_MYFH select_read_STDIN select_write_STDIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | socket_connects socket_stream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # returns the filename for a particular test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub generateTestfile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generateTestfile: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my $heap = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | return 'POE-' . $heap->{'current_version'} . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | '-' . $heap->{'current_loop'} . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | '-' . ( $heap->{'lite_tests'} ? 'LITE' : 'HEAVY' ) . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | '-' . ( $heap->{'current_assertions'} ? 'assert' : 'noassert' ) . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | '-' . ( $heap->{'current_noxsqueue'} ? 'noxsqueue' : 'xsqueue' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # maintains the mapping of the loop <-> real module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | my %poe2load = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 'Event' => 'Event', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 'IO_Poll' => 'IO::Poll', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 'Event_Lib' => 'Event::Lib', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 'EV' => 'EV', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 'Glib' => 'Glib', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 'Tk' => 'Tk', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 'Gtk' => 'Gtk', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 'Prima' => 'Prima', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 'Wx' => 'Wx', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 'Kqueue' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 'Select' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # returns the proper "load" stuff for a specific loop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub poeloop2load { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
poeloop2load: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $eventloop = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if ( exists $poe2load{ $eventloop } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | return $poe2load{ $eventloop }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | die "Unknown event loop!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # returns the version of the "real" installed module that the loop uses | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub loop2realversion { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loop2realversion: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $eventloop = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # Decide which event loop to use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ( ! defined $eventloop ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 12 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } elsif ( $eventloop eq 'Event' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | return $Event::VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } elsif ( $eventloop eq 'IO_Poll' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | return $IO::Poll::VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } elsif ( $eventloop eq 'Event_Lib' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | return $Event::Lib::VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } elsif ( $eventloop eq 'EV' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | return $EV::VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } elsif ( $eventloop eq 'Glib' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | return $Glib::VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } elsif ( $eventloop eq 'Tk' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return $Tk::VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } elsif ( $eventloop eq 'Gtk' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | return $Gtk::VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } elsif ( $eventloop eq 'Prima' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | return $Prima::VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } elsif ( $eventloop eq 'Wx' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | return $Wx::VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } elsif ( $eventloop eq 'Kqueue' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # FIXME how do I do this? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } elsif ( $eventloop eq 'Select' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | return 'BUILTIN'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # FIXME figure the XS stuff out! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # } elsif ( $eventloop eq 'XSPoll' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # return $POE::XS::Loop::Poll::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # } elsif ( $eventloop eq 'XSEpoll' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # return $POE::XS::Loop::EPoll::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | die "Unknown event loop!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # helper routine to parse times() output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | sub beautify_times { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
beautify_times: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my $string = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $origdata = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # split it up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $string =~ s/^\s+//; $string =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my @times = split( /\s+/, $string ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # make the data struct | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # ($user,$system,$cuser,$csystem) = times; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my $data = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 'u' => $times[4] - $times[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 's' => $times[5] - $times[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 'cu' => $times[6] - $times[2], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 'cs' => $times[7] - $times[3], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # add original data? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if ( $origdata ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $data->{'s_user'} = $times[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $data->{'s_sys'} = $times[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $data->{'s_cuser'} = $times[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $data->{'s_csys'} = $times[3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $data->{'e_user'} = $times[4]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $data->{'e_sys'} = $times[5]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $data->{'e_cuser'} = $times[6]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $data->{'e_csys'} = $times[7]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # send it back! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # returns a list of "known" POE loops | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub knownloops { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
knownloops: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # FIXME we remove Wx because I suck. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # FIXME I have no idea how to load/unload Kqueue... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # FIXME figure out the XS stuff! XSPoll XSEPoll | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | return [ qw( Event_Lib EV Glib Prima Gtk Tk Select IO_Poll ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||