# Executing a vector of expressions: some benchmarks

**URL:** <https://discourse.julialang.org/t/executing-a-vector-of-expressions-some-benchmarks/73500>\
**Category:** New to Julia\
**Tags:** metaprogramming, function, io\
**Created:** [December 22, 2021, 4:43pm UTC](https://discourse.julialang.org/t/executing-a-vector-of-expressions-some-benchmarks/73500 "2021-12-22T16:43:44Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [December 22, 2021, 5:23pm UTC](https://discourse.julialang.org/t/executing-a-vector-of-expressions-some-benchmarks/73500/4 "2021-12-22T17:23:56Z")

</div>

> [@Bardo](#):
>
> The generate / include file approach works as the original function, without eval.  
> I was struggling with IOBuffer’s read and write, any hint how to use it, as with the file?

Don’t work with strings—almost never build expressions using strings. Work with expressions. Like this, for example

```julia
genfun_expr(exprs, args...) =
    Expr(:function, Expr(:tuple, args...), Expr(:block, exprs...))

myfunc = eval(genfun_expr(evec, :a))
@btime $myfunc($a) # 2.863 ns (0 allocations: 0 bytes)

```

---

_[View the full topic](https://discourse.julialang.org/t/executing-a-vector-of-expressions-some-benchmarks/73500)._
