Re: [xsl] Performance differences between xsl:for-each and xsl:template matches

Subject: Re: [xsl] Performance differences between xsl:for-each and xsl:template matches
From: "Christophe Marchand cmarchand@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 17 Aug 2022 08:41:09 -0000
Right !

Trying to optimize bad-written, hard-to-maintain code is always an 
error. Start by having some clean code, respect SOLID principles, and 
then, probably, you won't still need to optimize it. Or, if you still 
need to optimize it, it'll be much better !

Christophe

Le 17/08/2022 C  09:10, Michael Kay mike@xxxxxxxxxxxx a C)critB :
> Well, this appears to be working code, and attempting to improve the 
> performance of working code is not "premature" - provided that you 
> have clear evidence that the working code doesn't meet the performance 
> requirements.
>
> What it does appear to be, though, is optimization by trial-and-error, 
> which is an equally common fault.
>
> But let's ignore the critique of methodology and try to answer the 
> question. There is no reason to believe that using apply-templates and 
> template rules should be faster than for-each. On the contrary, one 
> would expect it to be marginally slower. The reason for advising 
> people to use apply-templates is not for performance improvement, it 
> is to create code that is more robust and maintainable.
>
> Michael Kay
> Saxonica
>
>> On 16 Aug 2022, at 22:06, Dimitre Novatchev dnovatchev@xxxxxxxxx 
>> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>>
>> To quote Donald Knuth: "Premature optimization is the root of all 
>> evil" 
>> https://stackify.com/premature-optimization-evil/#:~:text=%E2%80%9CPremature%20optimization%20is%20the%20root,is%20credited%20to%20Donald%20Knuth.
>>
>> I think he discovered a general law that is true for all overzealous 
>> believers, as one can find ample proofs looking back in history.
>>
>> Or, as they say: "The road to hell is paved with good intentions".
>>
>>
>> Thanks,
>> Dimitre
>>
>>
>> On Tue, Aug 16, 2022 at 10:11 AM Edward Porter edward.porter@xxxxxxx 
>> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>>
>>     I inherited an older stylesheet that makes extensive use of
>>     <xsl:for-each> matching elements (e.g., select=b//chapter[@eid]b)
>>     in the root template to then call templates. Using Saxon, would
>>     there be any performance improvements if I refactored to use
>>     match templates and <xsl:apply-templates> as would generally be
>>     the best practice in this case?
>>
>>     -Ed
>>
>>     *Edward Porter*
>>
>>     Doc Publishing Tech Lead | Documentation Engineering - DevOps
>>
>>     Tel: + 1 919 531 2349 __
>>
>>     SAS | 100 Campus Drive | Cary, NC 27513
>>
>>     <image001.gif>
>>
>>     	
>>
>>     DID YOU KNOW?*_
>>     _**SAS IS THE NO. 1 AI AND ADVANCED ANALYTICS SOFTWARE PLATFORM.
>>     <https://www.sas.com/gms/redirect.jsp?detail=GMS114829_158201>*
>>
>>     XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
>>     EasyUnsubscribe
>>     <http://lists.mulberrytech.com/unsub/xsl-list/782854> (by email)
>>
>>
>>
>> -- 
>>
>> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
>> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> 
>> (by email)
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/2837134> 
> (by email <>)

Current Thread