Skip to content

Commit

Permalink
add two ELF.reduce benchmarks (apple#1069)
Browse files Browse the repository at this point in the history
Motivation:

As apple#1054 shows, we have some low-hanging performance fruit regarding
off-EventLoop future reduces. We should quantify those.

Modifications:

Add benchmarks to quantify the potential wins.

Result:

More benchmarks.
  • Loading branch information
weissi authored Jul 17, 2019
1 parent eeac3d5 commit 6b20fa5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Sources/NIOPerformanceTester/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -700,4 +700,19 @@ measureAndPrint(desc: "future_whenallcomplete_100k_deferred_on_loop") {
return allSucceeded.count
}

measureAndPrint(desc: "future_reduce_10k_futures") {
let el1 = group.next()

let oneHundredFutures = (1 ... 10_000).map { i in el1.makeSucceededFuture(i) }
return try! EventLoopFuture<Int>.reduce(0, oneHundredFutures, on: el1, +).wait()
}

measureAndPrint(desc: "future_reduce_into_10k_futures") {
let el1 = group.next()

let oneHundredFutures = (1 ... 10_000).map { i in el1.makeSucceededFuture(i) }
return try! EventLoopFuture<Int>.reduce(into: 0, oneHundredFutures, on: el1, { $0 += $1 }).wait()
}


try measureAndPrint(desc: "channel_pipeline_1m_events", benchmark: ChannelPipelineBenchmark.self)

0 comments on commit 6b20fa5

Please # to comment.