-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
84 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module bench | ||
|
||
go 1.22.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
func main() { | ||
fmt.Println("hello world") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package main | ||
|
||
import ( | ||
"sync" | ||
"testing" | ||
) | ||
|
||
// go test -bench=. -benchtime=1000000000x -count 5 | ||
func BenchmarkParallel(b *testing.B) { | ||
const capacity = 16 | ||
const parallelism = 10000 | ||
|
||
elementsPerChannel := b.N / parallelism | ||
|
||
var wg sync.WaitGroup | ||
|
||
for i := 0; i < parallelism; i++ { | ||
c := make(chan int, capacity) | ||
|
||
wg.Add(1) | ||
go func() { | ||
defer wg.Done() | ||
for j := 0; j < elementsPerChannel; j++ { | ||
c <- 91 | ||
} | ||
}() | ||
|
||
wg.Add(1) | ||
go func() { | ||
defer wg.Done() | ||
for j := 0; j < elementsPerChannel; j++ { | ||
<-c | ||
} | ||
}() | ||
} | ||
|
||
wg.Wait() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d2e8d82
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
1.20
.com.softwaremill.jox.ParallelBenchmark.parallelChannels ( {"capacity":"100","parallelism":"10000"} )
52.425892596666664
ns/op35.952803159999995
ns/op1.46
com.softwaremill.jox.ParallelKotlinBenchmark.parallelChannels_defaultDispatcher ( {"capacity":"16","parallelism":"10000"} )
37.563847839999994
ns/op25.054834629
ns/op1.50
This comment was automatically generated by workflow using github-action-benchmark.
CC: @adamw