| [reply] |
# ./show_me_the_problem.sh
****************************
here are the two programs:
-rwxr-xr-x 1 root root 177 wrz 30 17:57 run_fast.pl
-rwxr-xr-x 1 root root 190 wrz 30 17:57 run_slow.pl
****************************
the difference is:
10c10,11
< my $lst = list_extr(\( "(" . $inp . ")" ));
---
> my $par = "(" . $inp . ")";
> my $lst = list_extr(\$par);
****************************
data is the same... let's run them...
time ./run_fast.pl | wc -l
9506
real 0m0.476s
user 0m0.456s
sys 0m0.016s
****************************
time ./run_slow.pl | wc -l
9506
real 0m22.591s
user 0m22.556s
sys 0m0.012s
****************************
seee... programs are almost the same... but their time is totally dife
+erent
| [reply] [d/l] |
I removed the no autovivification line from libr_data as I haven't got a perl to hand with that module installed, and both programs ran fast for me for all perls from 5.10.0 through 5.24.0. So that might be a thing for you to investigate first.
Dave.
| [reply] [d/l] [select] |
| [reply] |
The program doesn't stop at any of regexpes. It finishes computations sucessfully, but sometimes it takes quite short, and sometimes it takes very long.
For example on 2Mb of data, when I call "list_extr" like this:
list_extr(\( "(" . $big_string . ")" ));
it takes only half a second. But if I call like this:
my $ttt = "(" . $big_string . ")";
list_extr(\$ttt);
it takes 20 seconds (slower 40x times). Why? Both ways look the same -- make string with parentheses around old string, take reference to it, do same computations. So if they are the same why the difference in time? I think perl is doing some magic here, but only someone more expierenced would tell.
| [reply] [d/l] [select] |
| [reply] |