1 Star 0 Fork 0

liangwup1123/gospeed

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
concurrency_benchmark_test.go 10.21 KB
一键复制 编辑 原始数据 按行查看 历史
Eleanor McHugh 提交于 2015-09-26 23:52 . Expanded StringChannelWrite tests
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
package gospeed
import "testing"
func BenchmarkConcurrentMakeChannelBoolUnbuffered(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = make(chan bool)
}
}
func BenchmarkConcurrentMakeChannelBool1(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = make(chan bool, 1)
}
}
func BenchmarkConcurrentMakeChannelBool10(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = make(chan bool, 10)
}
}
func BenchmarkConcurrentMakeChannelStringUnbuffered(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = make(chan string)
}
}
func BenchmarkConcurrentMakeChannelString1(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = make(chan string, 1)
}
}
func BenchmarkConcurrentMakeChannelString10(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = make(chan string, 10)
}
}
func BenchmarkConcurrentGo(b *testing.B) {
for i := 0; i < b.N; i++ {
go func() {}()
}
}
func BenchmarkConcurrentMakeSyncChannelAndClose(b *testing.B) {
for i := 0; i < b.N; i++ {
close(make(chan bool))
}
}
func BenchmarkConcurrentMakeASyncChannelAndClose1(b *testing.B) {
for i := 0; i < b.N; i++ {
close(make(chan bool, 1))
}
}
func BenchmarkConcurrentMakeASyncChannelAndClose10(b *testing.B) {
for i := 0; i < b.N; i++ {
close(make(chan bool, 10))
}
}
func BenchmarkConcurrentMakeASyncChannelAndClose100(b *testing.B) {
for i := 0; i < b.N; i++ {
close(make(chan bool, 100))
}
}
func BenchmarkConcurrentMakeASyncChannelAndClose1000(b *testing.B) {
for i := 0; i < b.N; i++ {
close(make(chan bool, 1000))
}
}
func BenchmarkConcurrentSyncBoolChannelWrite1(b *testing.B) {
b.StopTimer()
c := make(chan bool)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
c <- true
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentSyncBoolChannelWrite10(b *testing.B) {
b.StopTimer()
c := make(chan bool)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 10; j > 0; j-- {
c <- true
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentSyncBoolChannelWrite100(b *testing.B) {
b.StopTimer()
c := make(chan bool)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 100; j > 0; j-- {
c <- true
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentSyncBoolChannelWrite1000(b *testing.B) {
b.StopTimer()
c := make(chan bool)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 1000; j > 0; j-- {
c <- true
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentASyncBoolChannelWrite1(b *testing.B) {
b.StopTimer()
c := make(chan bool, 1)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
c <- true
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentASyncBoolChannelWrite10(b *testing.B) {
b.StopTimer()
c := make(chan bool, 10)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 10; j > 0; j-- {
c <- true
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentASyncBoolChannelWrite100(b *testing.B) {
b.StopTimer()
c := make(chan bool, 100)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 100; j > 0; j-- {
c <- true
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentASyncBoolChannelWrite1000(b *testing.B) {
b.StopTimer()
c := make(chan bool, 1000)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 1000; j > 0; j-- {
c <- true
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentSyncStringChannelWrite0x1(b *testing.B) {
b.StopTimer()
c := make(chan string)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
c <- ""
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentSyncStringChannelWrite0x10(b *testing.B) {
b.StopTimer()
c := make(chan string)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 10; j > 0; j-- {
c <- ""
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentSyncStringChannelWrite0x100(b *testing.B) {
b.StopTimer()
c := make(chan string)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 100; j > 0; j-- {
c <- ""
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentSyncStringChannelWrite0x1000(b *testing.B) {
b.StopTimer()
c := make(chan string)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 1000; j > 0; j-- {
c <- ""
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentASyncStringChannelWrite0x1(b *testing.B) {
b.StopTimer()
c := make(chan string, 1)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
c <- ""
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentASyncStringChannelWrite0x10(b *testing.B) {
b.StopTimer()
c := make(chan string, 10)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 10; j > 0; j-- {
c <- ""
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentASyncStringChannelWrite0x100(b *testing.B) {
b.StopTimer()
c := make(chan string, 100)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 100; j > 0; j-- {
c <- ""
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentASyncStringChannelWrite0x1000(b *testing.B) {
b.StopTimer()
c := make(chan string, 1000)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 1000; j > 0; j-- {
c <- ""
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentSyncStringChannelWrite1x1(b *testing.B) {
b.StopTimer()
c := make(chan string)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
c <- "h"
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentSyncStringChannelWrite1x10(b *testing.B) {
b.StopTimer()
c := make(chan string)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 10; j > 0; j-- {
c <- "h"
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentSyncStringChannelWrite1x100(b *testing.B) {
b.StopTimer()
c := make(chan string)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 100; j > 0; j-- {
c <- "h"
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentSyncStringChannelWrite1x1000(b *testing.B) {
b.StopTimer()
c := make(chan string)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 1000; j > 0; j-- {
c <- "h"
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentASyncStringChannelWrite1x1(b *testing.B) {
b.StopTimer()
c := make(chan string, 1)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
c <- "h"
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentASyncStringChannelWrite1x10(b *testing.B) {
b.StopTimer()
c := make(chan string, 10)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 10; j > 0; j-- {
c <- "h"
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentASyncStringChannelWrite1x100(b *testing.B) {
b.StopTimer()
c := make(chan string, 100)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 100; j > 0; j-- {
c <- "h"
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentASyncStringChannelWrite1x1000(b *testing.B) {
b.StopTimer()
c := make(chan string, 1000)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 1000; j > 0; j-- {
c <- "h"
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentSyncStringChannelWrite10x1(b *testing.B) {
b.StopTimer()
c := make(chan string)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
c <- "hellohello"
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentSyncStringChannelWrite10x10(b *testing.B) {
b.StopTimer()
c := make(chan string)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 10; j > 0; j-- {
c <- "hellohello"
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentSyncStringChannelWrite10x100(b *testing.B) {
b.StopTimer()
c := make(chan string)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 100; j > 0; j-- {
c <- "hellohello"
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentSyncStringChannelWrite10x1000(b *testing.B) {
b.StopTimer()
c := make(chan string)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 1000; j > 0; j-- {
c <- "hellohello"
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentASyncStringChannelWrite10x1(b *testing.B) {
b.StopTimer()
c := make(chan string, 1)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
c <- "hellohello"
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentASyncStringChannelWrite10x10(b *testing.B) {
b.StopTimer()
c := make(chan string, 10)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 10; j > 0; j-- {
c <- "hellohello"
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentASyncStringChannelWrite10x100(b *testing.B) {
b.StopTimer()
c := make(chan string, 100)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 100; j > 0; j-- {
c <- "hellohello"
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
func BenchmarkConcurrentASyncStringChannelWrite10x1000(b *testing.B) {
b.StopTimer()
c := make(chan string, 1000)
go func() {
for _ = range c {
}
}()
b.StartTimer()
for i := 0; i < b.N; i++ {
for j := 1000; j > 0; j-- {
c <- "hellohello"
}
}
b.StopTimer()
close(c)
b.StartTimer()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/liangwup1123/gospeed.git
git@gitee.com:liangwup1123/gospeed.git
liangwup1123
gospeed
gospeed
master

搜索帮助