in reply to Re: Context search term highlighting - Perl is too slow
in thread Context search term highlighting - Perl is too slow

Can the nested loops be avoided? That's a good question.

The problem is that I have to map between the words I'm comparing and the original "un-modified" text.

Anyway, here's an example that runs.

http://hank.org/modules/PhraseTest.pm

(I think PerlMonk's wrapping code is too agressive in code blocks)

> dprofpp -u -p PhraseTest.pm Total Elapsed Time = 0.506468 Seconds User Time = 0.508234 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 61.0 0.310 0.430 30 0.0103 0.0143 PhraseHighlight::highligh +t_text 15.7 0.080 0.080 30 0.0027 0.0027 PhraseHighlight::build_hi +ghlighted _text 5.90 0.030 0.030 30 0.0010 0.0010 PhraseHighlight::substitu +e_highlig ht 3.94 0.020 0.020 15 0.0013 0.0013 Text::Wrap::wrap 1.97 0.010 0.010 30 0.0003 0.0003 PhraseHighlight::join_wor +ds 1.97 0.010 0.010 1 0.0100 0.0100 warnings::BEGIN 1.97 0.010 0.020 1 0.0100 0.0200 vars::BEGIN 1.97 0.010 0.010 2 0.0050 0.0050 PhraseHighlight::BEGIN 0.00 0.000 -0.000 2 0.0000 - vars::import 0.00 0.000 -0.000 3 0.0000 - Text::Tabs::BEGIN 0.00 0.000 -0.000 2 0.0000 - result::BEGIN 0.00 0.000 -0.000 4 0.0000 - constant::BEGIN 0.00 0.000 -0.000 1 0.0000 - warnings::register::impor +t 0.00 0.000 -0.000 2 0.0000 - warnings::register::mkMas +k 0.00 0.000 -0.000 1 0.0000 - strict::unimport
Thanks,