diff options
| author | Paul Buetow <paul@buetow.org> | 2012-06-23 11:56:02 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2012-06-23 11:56:02 +0200 |
| commit | 9fc4f1d1cfe90b953ccd89322930e1dd7f176a4e (patch) | |
| tree | eaa923d97531a1fd640452da7bb613049d2cc69a /lib/Loadbars/Main.pm | |
| parent | 1ae5097b890ecc6ef950b8f70cf2902bfe193cbc (diff) | |
use more precompiled regexp, initial network stats
Diffstat (limited to 'lib/Loadbars/Main.pm')
| -rw-r--r-- | lib/Loadbars/Main.pm | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/Loadbars/Main.pm b/lib/Loadbars/Main.pm index 361cf2c..f117a9d 100644 --- a/lib/Loadbars/Main.pm +++ b/lib/Loadbars/Main.pm @@ -89,7 +89,6 @@ sub stats_thread ($;$) { $user = defined $user ? "-l $user" : ''; my ( $sigusr1, $sigterm ) = ( 0, 0 ); - my $loadavgexp = qr/(\d+\.\d{2}) (\d+\.\d{2}) (\d+\.\d{2})/; my $inter = Loadbars::Constants->INTERVAL; until ($sigterm) { @@ -127,15 +126,16 @@ BASH $SIG{USR1} = sub { $sigusr1 = 1 }; $SIG{TERM} = sub { $sigterm = 1 }; + # Precompile some regexp + my $loadavgexp = qr/(\d+\.\d{2}) (\d+\.\d{2}) (\d+\.\d{2})/; my $cpu_re = qr/$I{cpuregexp}/; - - # 0=cpu, 1=mem, 2=net - my $mode = 0; - my @meminfo = map { [$_, qr/^$_: *(\d+)/] } (qw(MemTotal MemFree Buffers Cached SwapTotal SwapFree)); + # 0=cpu, 1=mem, 2=net + my $mode = 0; + while (<$pipe>) { chomp; @@ -180,7 +180,6 @@ BASH } if ($sigusr1) { - # TODO: Use index instead of regexp for cpuregexp $cpu_re = qr/$I{cpuregexp}/; $sigusr1 = 0; |
