summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-04-03 00:25:12 +0300
committerPaul Buetow <paul@buetow.org>2025-04-03 00:25:12 +0300
commit1dd57067b528e1889a798a7b6d243110c87454d0 (patch)
tree3fee26d1a72b76995d1d8e5ae08c47b87bd594f4
initial comimt
-rw-r--r--README.md3
-rw-r--r--go.mod3
-rw-r--r--main.go5
-rw-r--r--main_test.go16
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
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..96d4b17
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,3 @@
+module codeberg.org/snonux/gbench
+
+go 1.24.1
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..344d51f
--- /dev/null
+++ b/main.go
@@ -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
+}