<p>If I had to guess, I'd say a macro would be faster because it's accessing the file system less.  In any case, unless you're dealing with hundreds of thousands of calls, I'd also guess that's the difference is going to be negligible for most use cases.</p>

CC BY-SA 3.0
2015-03-12T22:10:48.443Z
2015-03-12T22:10:48.443Z
Brad Bell
<p>Which is better for performance? Using a macro for output in a for loop or calling an include using the 'with' params to pass data? Both are loading a file. But is stacking up a bunch of code in a macro file faster than using an small include file? </p>

<pre><code>{% for item in entries %}
    {% include "/components/_item" with { item: item } %}
{% endfor %}
</code></pre>

<p>OR</p>

<pre><code>{% for item in entries %}
    {{ helpers.item(item) }}
{% endfor %}
</code></pre>

<performance><include><macro>
For performance is using a macro better than using include with the 'with' statement?
# For performance is using a macro better than using include with the 'with' statement?

(Asked by: username_0 on 2015-03-12)

Which is better for performance? Using a macro for output in a for loop or calling an include using the 'with' params to pass data? Both are loading a file. But is stacking up a bunch of code in a macro file faster than using an small include file? 
{% for item in entries %}
    {% include "/components/_item" with { item: item } %}
{% endfor %}

OR
{% for item in entries %}
    {{ helpers.item(item) }}
{% endfor %}

**Tags:** performance, include, macro


---

## 1 answers

### Answer by username_1 on 2015-03-12. Score: 4 | Accepted answer

If I had to guess, I'd say a macro would be faster because it's accessing the file system less. In any case, unless you're dealing with hundreds of thousands of calls, I'd also guess that's the difference is going to be negligible for most use cases.


---

