Skip to content

Commit

Permalink
bench with foldLeft vs reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
sritchie committed Jan 13, 2022
1 parent dfeafa1 commit 8232a9a
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class MomentsBenchmark {

@Benchmark
def timePlusMoments(state: MomentsState, bh: Blackhole): Unit =
bh.consume(state.inputMoments.reduce(_ + _))
bh.consume(
state.inputMoments.foldLeft(Moments.momentsMonoid.zero)(_ + _)
)

@Benchmark
def timeSumOption(state: MomentsState, bh: Blackhole): Unit =
Expand Down

0 comments on commit 8232a9a

Please sign in to comment.