# ByRow vs broadcasting performance

**URL:** <https://discourse.julialang.org/t/byrow-vs-broadcasting-performance/86069>\
**Category:** Performance\
**Tags:** question\
**Created:** [August 20, 2022, 4:42pm UTC](https://discourse.julialang.org/t/byrow-vs-broadcasting-performance/86069 "2022-08-20T16:42:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Post date:** [August 20, 2022, 4:42pm UTC](https://discourse.julialang.org/t/byrow-vs-broadcasting-performance/86069/1 "2022-08-20T16:42:46Z")

</div>

I was under the impression that ByRow would have better performance than broadcasting. However, trying an example today I found that it seems to be the other way. It may be due to some specific characteristic of my example. In any case, what is the reason for this?

```julia
df1 = DataFrame(A = rand(20), B = Float.(collect(1:20)));
# 9.500 μs (144 allocations: 7.91 KiB)
@btime transform(df1, [:A, :B] => ((x, y) -> x .+ y) => :Sum)
df1 = DataFrame(A = rand(20), B = Float.(collect(1:20)));
# 41.400 μs (358 allocations: 24.41 KiB)
transform(df1, [:A, :B] => ByRow((x, y) -> x + y) => :Sum)

```
