# Coding performance

**URL:** <https://discourse.nodered.org/t/coding-performance/42984>\
**Category:** General\
**Created:** [22 March 2021 07:04 UTC](https://discourse.nodered.org/t/coding-performance/42984 "2021-03-22T07:04:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [22 March 2021 07:04 UTC](https://discourse.nodered.org/t/coding-performance/42984/1 "2021-03-22T07:04:06Z")

</div>

I'm sorry for the possible trivial question: in my project there are a lot of switch nodes which detect if the msg.paylod string is equal to certain coded frames. From the performance/speed point of view, is more efficient a switch node, or a function node containing just:

```auto
 if (msg.payload === "foo") {
	return msg;
}
return

```

??  
Thanks

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [22 March 2021 07:20 UTC](https://discourse.nodered.org/t/coding-performance/42984/2 "2021-03-22T07:20:15Z")

</div>

The switch node will be more efficient

---

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [22 March 2021 07:57 UTC](https://discourse.nodered.org/t/coding-performance/42984/3 "2021-03-22T07:57:32Z")

</div>

Thanks 👍

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [21 May 2021 07:58 UTC](https://discourse.nodered.org/t/coding-performance/42984/4 "2021-05-21T07:58:20Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
