I first load the hash with only the test name that i'm interested to extract then use the code below to do the actual extraction into a text file.
i've ran just a while loop going through the file, and it takes about 25secs, and when i ran it through my code below, it takes about 52secs.
any other helpful advice? thanks~
## extract all the param values from the stdf sub get_paramValue { my ($stdf,$lot,$oper,$sum,%param_flag) = @_; my ($output); print "Running with stdf:$stdf.\n"; &log("get_paramValue","Running with stdf:$stdf."); if(-e $stdf){ ## create the output file name, similar to the stdf name but w +ith .log ext $output = $outputdir.$lot."_".$oper."_".$sum.".log"; open(OUT, ">$output") or &log("get_paramValue","Can't write to + output: $output"); print OUT "tname,idx,param_val\n"; open(STDF, $stdf) or &log("get_paramValue","Die can't read fro +m stdf:$stdf."); my (@tmp,$testname,$testFound,$paramVal,$unit_count); while(<STDF>){ if(/3_prtnm_/){ @tmp = split(/3_prtnm_/); $unit_count = &trim($tmp[1]); } elsif(/2_tname_/){ @tmp = split(/2_tname_/); $testname = &trim($tmp[1]); if(exists $param_flag{$testname}){ $testFound = 1; } } elsif($testFound){ if(/2_mrslt_/){ @tmp = split(/2_mrslt_/); $paramVal = &trim($tmp[1]); print OUT "$testname,$unit_count,$paramVal\n"; $testFound = 0; } } } ## END while close(STDF); close(OUT); } ## END IF return $output; } ## end sub

In reply to Re^2: How to speed up/multi thread extract from txt files? by MelaOS
in thread How to speed up/multi thread extract from txt files? by MelaOS

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.