This is more out of curiosity than anything else, as I cannot find any useful information about Google about this function (CORE :: substcont)
In profiling and optimizing old, slow, syntactic XML code, I found that the following regular expression calls substcont 31 times each time a line is executed, and takes a huge amount of time:
Calls: 10000 Time: 2.65s Sub-elections: 320,000 Time in submarines: 1.15s`
$handle =~s/(>)\s*(<)/$1\n$2/g;
Compared to the previous line:
Calls: 10,000 Time: 371ms Sub-conclusions: 30,000 Time in submarines: 221 ms
$handle =~s/(.*)\s*(<\?)/$1\n$2/g;
The number of subscript calls is quite surprising, especially considering that I would have thought that the second regular expression would be more expensive. This is obviously why profiling is a good thing -)
I subsequently modified both of these lines to remove unnecessary backrefs, with sharp results for a poorly managed line:
Calls: 10000 Time: 393ms Sub-elections: 10000 Time in the submarine: 341 ms
$handle =~s/>\s*</>\n</g;
- So my question is: why does the original make SO many calls to substcont, and what does substcont do even in the regex engine, which takes so long?
optimization profiling regex perl
paulw1128
source share