Plugin Performance Surprise
Posted:
Tue Nov 13, 2012 5:32 am
by jhb50
I was wondering why one of my plugins was taking so long to refresh so by adding log messages to each step of the code I timed it and found.
Due to this regex
Extracts took 5 sec each
Now with this regex
Extracts take 1 sec each!
Can you believe it?
Can you explain it?
Re: Plugin Performance Surprise
Posted:
Tue Nov 13, 2012 9:47 am
by zip
the regex is different, so that's why
Re: Plugin Performance Surprise
Posted:
Tue Nov 13, 2012 4:37 pm
by jhb50
So you don't understand regex either?
Kinda important when the big issue with Serviio is the time required to constantly refresh all the online feeds even if they are not being used.
Re: Plugin Performance Surprise
Posted:
Tue Nov 13, 2012 4:59 pm
by zip
It's called lazy quantifiers.
http://www.asiteaboutnothing.net/regex/regex-greed.htmlI'm not sure how it's implemented in Groovy/Java, but it looks like it's slower than greedy expression. Use it only if you need it.
Re: Plugin Performance Surprise
Posted:
Wed Nov 14, 2012 3:09 am
by jhb50
My conclusion is opposite to yours, and lazy will stop as soon as it gets a match whereas greedy will continue and then backtrack.
I'm only using lazy so it should be fast and I read (?s).*?'file'.*?'(.*?)' as read the html string up to 'file' and then up to the next ' and then capture to the next quote and stop. However I read (?s)'file'.*?'(.*?)' the same way but it takes 5 times longer so something is different.
Re: Plugin Performance Surprise
Posted:
Thu Nov 15, 2012 2:09 am
by miksa
jhb50 wrote:Due to this regex
Extracts took 5 sec each
Now with this regex
Extracts take 1 sec each!
i can see that first regex has 4 pattens and second only 3. that might explain difference in performance. i guess execution of each pattern takes extra time.