Macros vs Include recursive: Create Menu

I create a tree menu with:

<!--includes/menu-links.html-->
{% for link in links %}
    <li>
        <a href="{{ link.href }}">{{ link.name }}</a>
        {% if link.sublinks %}
            <ul>
                {% include "includes/menu-links.html" with ['links': link.sublinks] %}
            </ul>
        {% endif %}
    </li>
{% endfor %}

call:

<ul class="main-menu">
    {% include "includes/menu-links.html" with ['links':links] %}
</ul>

or

<!--macros/menu-macros.html-->
{% macro menu_links(links) %}
    {% for link in links %}
        <li>
            <a href="{{ link.href }}">{{ link.name }}</a>
            {% if link.sublinks %}
                <ul>
                    {{ menu_links(link.sublinks) }}
                </ul>
            {% endif %}
        </li>
    {% endfor %}
{% endmacro %}

call:

<ul class="main-menu">
    {{ macros.menu_links(links) }}
</ul>

What approach would have a better performance?



60.8k

you can test it yourself http://stackoverflow.com/questions/535020/tracking-the-script-execution-time-in-php

anyways i doubt there will be any difference.

Please post the results afterwards