diff options
| author | Paul Buetow <paul@buetow.org> | 2025-04-03 00:25:12 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-04-03 00:25:12 +0300 |
| commit | 1dd57067b528e1889a798a7b6d243110c87454d0 (patch) | |
| tree | 3fee26d1a72b76995d1d8e5ae08c47b87bd594f4 | |
initial comimt
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | go.mod | 3 | ||||
| -rw-r--r-- | main.go | 5 | ||||
| -rw-r--r-- | main_test.go | 16 |
4 files changed, 27 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..21dfafc --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Silly Benchmark + +To compare how fast this runs on FreeBSD vs a Linux Bhyve VM @@ -0,0 +1,3 @@ +module codeberg.org/snonux/gbench + +go 1.24.1 @@ -0,0 +1,5 @@ +package main + +func main() { + println("Hello world") +} diff --git a/main_test.go b/main_test.go new file mode 100644 index 0000000..9af507e --- /dev/null +++ b/main_test.go @@ -0,0 +1,16 @@ +package main + +import "testing" + +func BenchmarkSilly(b *testing.B) { + var sillyResult float64 + for i := 0; i < b.N; i++ { + sillyResult += float64(i) + sillyResult *= float64(i) + divisor := float64(i) + 1 + if divisor > 0 { + sillyResult /= divisor + } + } + _ = sillyResult // to avoid compiler optimization +} |
