insta-purty via perltidy
This commit is contained in:
parent
64b8d22d37
commit
1dcc7cb877
45
script.pl
45
script.pl
@ -10,15 +10,14 @@ use Text::SimpleTable::AutoWidth;
|
|||||||
use WWW::Mechanize ();
|
use WWW::Mechanize ();
|
||||||
my $mech = WWW::Mechanize->new();
|
my $mech = WWW::Mechanize->new();
|
||||||
my $url =
|
my $url =
|
||||||
'https://www.mersenne.org/results/?extf=1&exp1=1&execm=1&excert=1&exp_lo=2&exp_hi=&limit=10000';
|
'https://www.mersenne.org/results/?extf=1&exp1=1&execm=1&excert=1&exp_lo=2&exp_hi=&limit=10000';
|
||||||
$mech->get($url);
|
$mech->get($url);
|
||||||
$mech->submit_form(
|
$mech->submit_form(
|
||||||
form_number => 1,
|
form_number => 1,
|
||||||
fields => {
|
fields => {
|
||||||
user_login => 'secret',
|
user_login => 'secret',
|
||||||
user_password => 'secret',
|
user_password => 'secret',
|
||||||
}
|
} );
|
||||||
);
|
|
||||||
|
|
||||||
# load the results into a table object
|
# load the results into a table object
|
||||||
my $html_string = $mech->content();
|
my $html_string = $mech->content();
|
||||||
@ -31,34 +30,34 @@ my $list;
|
|||||||
|
|
||||||
my $ts = $te->first_table_found();
|
my $ts = $te->first_table_found();
|
||||||
foreach my $row ( $ts->rows ) {
|
foreach my $row ( $ts->rows ) {
|
||||||
foreach my $cell ($row) {
|
foreach my $cell ($row) {
|
||||||
my $machine = @$cell[0];
|
my $machine = @$cell[0];
|
||||||
my $ghz_days = @$cell[6];
|
my $ghz_days = @$cell[6];
|
||||||
$ghz_days =~ s/\s//g;
|
$ghz_days =~ s/\s//g;
|
||||||
my $days = @$cell[4];
|
my $days = @$cell[4];
|
||||||
$days =~ s/\s//g;
|
$days =~ s/\s//g;
|
||||||
|
|
||||||
if ( $days > 0 ) {
|
if ( $days > 0 ) {
|
||||||
my $perf = $ghz_days / $days;
|
my $perf = $ghz_days / $days;
|
||||||
push( @{ $list->{$machine} }, $perf );
|
push( @{ $list->{$machine} }, $perf );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# create hash with each comptuer and its average GHz Days per day
|
# create hash with each comptuer and its average GHz Days per day
|
||||||
my %ranks;
|
my %ranks;
|
||||||
foreach my $key ( keys %$list ) {
|
foreach my $key ( keys %$list ) {
|
||||||
my $mean = sum( @{ $list->{$key} } ) / @{ $list->{$key} };
|
my $mean = sum( @{ $list->{$key} } ) / @{ $list->{$key} };
|
||||||
my $rounded = int( $mean + 0.5 );
|
my $rounded = int( $mean + 0.5 );
|
||||||
$ranks{$key} = $rounded;
|
$ranks{$key} = $rounded;
|
||||||
}
|
}
|
||||||
|
|
||||||
# sort hash by the average and print to screen
|
# sort hash by the average and print to screen
|
||||||
my $tbl =
|
my $tbl =
|
||||||
Text::SimpleTable::AutoWidth->new(
|
Text::SimpleTable::AutoWidth->new(
|
||||||
captions => [qw/ Computer GHZDaysPerDay /] );
|
captions => [qw/ Computer GHZDaysPerDay /] );
|
||||||
foreach my $key ( reverse sort { $ranks{$a} <=> $ranks{$b} } keys(%ranks) ) {
|
foreach my $key ( reverse sort { $ranks{$a} <=> $ranks{$b} } keys(%ranks) ) {
|
||||||
$tbl->row( $key, $ranks{$key} );
|
$tbl->row( $key, $ranks{$key} );
|
||||||
}
|
}
|
||||||
say $tbl->draw();
|
say $tbl->draw();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user