Skip to content

Commit

Permalink
remove benchmark that used atomic.Bool
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley committed Oct 10, 2023
1 parent 390aed9 commit e32f4f1
Showing 1 changed file with 0 additions and 39 deletions.
39 changes: 0 additions & 39 deletions benchmark/primitives/primitives_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,42 +425,3 @@ func BenchmarkRLockUnlock(b *testing.B) {
}
})
}

type ifNop interface {
nop()
}

type alwaysNop struct{}

func (alwaysNop) nop() {}

type concreteNop struct {
isNop atomic.Bool
i int
}

func (c *concreteNop) nop() {
if c.isNop.Load() {
return
}
c.i++
}

func BenchmarkInterfaceNop(b *testing.B) {
n := ifNop(alwaysNop{})
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
n.nop()
}
})
}

func BenchmarkConcreteNop(b *testing.B) {
n := &concreteNop{}
n.isNop.Store(true)
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
n.nop()
}
})
}

0 comments on commit e32f4f1

Please sign in to comment.