[mrtg] OT: perl vs shell cmd

Beast beast at i6x.org
Tue Jun 14 10:09:47 MEST 2005


Supose I want to parse a big log file (~500MB/4mil lines), which one is
faster and use less memory:


$ ./parser.pl logfile.log

or

$ grep 'Jun 14 03:' | ./parser.pl

Log file is 24 hours and it will be processed every hour.

------
parser.pl:
$in_time = 'Jun 14 03:';

while(<>)
{
    if(/^$in_time/ {
       # do some processing
    }else {
       next;
    }
}


-- 

--beast


--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://lists.ee.ethz.ch/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi



More information about the mrtg mailing list