Why the best way to define a function from a performance perspective is to use the expr.Function option. #767
Replies: 4 comments
-
This is great, very helpful! I've wondered about this since I make heavy use of functions. It's nice to have data. |
Beta Was this translation helpful? Give feedback.
-
Nice benchmark! I put a lot of effort to make function calls as fast as possible. This is still true: The best way to define a function from a performance perspective is to use a Function option. In your case the map slightly outperforms Function due to a heavy ammount of optimizations. But for general, uncommon func signature results will be different. True for example: func(int, string, int, time.Time, uin16) or any other random funcs signatures. |
Beta Was this translation helpful? Give feedback.
-
For such a function |
Beta Was this translation helpful? Give feedback.
-
Faster. But on how much - benchmarks are needed. |
Beta Was this translation helpful? Give feedback.
-
Quoted from documentation(https://expr-lang.org/docs/functions)
This is my benchmark test:
And result
The performance of map and function methods are very close, there is no particularly obvious difference, and map method is even faster.
Beta Was this translation helpful? Give feedback.
All reactions