AI-Fuzzy

 view release on metacpan or  search on metacpan

demo/cpu.pl  view on Meta::CPAN

use strict;
use warnings;

use AI::Fuzzy;
my $f = new AI::Fuzzy::Label;

$f->addlabel("completely idle",       99,   100, 101);
$f->addlabel("very idle",       90,   95, 100);
$f->addlabel("idle",   		80,   87,  92);
$f->addlabel("somewhat idle",   40,   65,  80);
$f->addlabel("somewhat busy",   20,   45 , 60);
$f->addlabel("busy",            8,    13,  20);
$f->addlabel("very busy",        0,   5,  10);
$f->addlabel("completely busy",  -1,  0,  1);


my $count=100;

while (1) {
   open (STAT, "vmstat -n 1 $count |") or die ("can't find vmstat"); 
 
   my $cpu = <STAT>;    # headers
   $cpu = <STAT>;	    # headers



( run in 0.227 second using v1.01-cache-2.11-cpan-87723dcf8b7 )