reworking how I actually want to publish the telemetry data for now

This commit is contained in:
2026-03-06 14:30:52 +00:00
parent 9b10042112
commit 6e98f13eb5
4 changed files with 180 additions and 39 deletions
+36
View File
@@ -0,0 +1,36 @@
package telemetry
import (
"testing"
)
// Old Way
type TelemetryFieldAny struct {
Value any
}
// New Way
type TelemetryFieldUint struct {
Raw uint64
}
func BenchmarkInterfaceBoxing(b *testing.B) {
var field TelemetryFieldAny
b.ReportAllocs() // Tracks memory allocations
for i := 0; i < b.N; i++ {
// Every iteration, we put a uint16 into 'any'
// This forces a heap allocation in many Go versions
field.Value = uint16(i % 65535)
}
_ = field
}
func BenchmarkUint64Bucket(b *testing.B) {
var field TelemetryFieldUint
b.ReportAllocs()
for i := 0; i < b.N; i++ {
// Casting to uint64 is a direct CPU register move
field.Raw = uint64(uint16(i % 65535))
}
_ = field
}