Skip to content

Commit fbb1767

Browse files
committed
code: Add new code section for benchmarks, code samples, etc...
1 parent 25c5dd4 commit fbb1767

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

code/go/generic_bench_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package main
2+
3+
import (
4+
"sync/atomic"
5+
"testing"
6+
)
7+
8+
func Benchmark_atomicBoolLoad(b *testing.B) {
9+
10+
var atomicB atomic.Bool
11+
atomicB.Store(true)
12+
13+
for b.Loop() {
14+
_ = atomicB.Load()
15+
}
16+
}
17+
18+
func Benchmark_nonAtomicBoolLoad(b *testing.B) {
19+
20+
var nonAtmicB bool = true
21+
22+
for b.Loop() {
23+
_ = nonAtmicB
24+
}
25+
}

code/go/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/jrasell/dev-mess
2+
3+
go 1.25.4

0 commit comments

Comments
 (0)