Memory usage improvements

Improved the memory usage of the ReadData function. Pretty low footprint
now
This commit is contained in:
2026-07-01 14:39:39 +01:00
parent 31140b5df4
commit c3ee9c0f44
4 changed files with 159 additions and 45 deletions
+30 -2
View File
@@ -1,4 +1,32 @@
# BeamNG SDK
Simple SDK to interact with BeamNG.drive OutGauge data.
There's some features missing listed in a comment in the
`outgauge.go` file. I will implement them as necessary.
## Development
### Performance
`go test -bench=BenchmarkReadData -benchmem -memprofile=mem.pprof`
replace the function to be tested
Use `go tool pprof` to analyze the results
#### Results
```bash
# Previous footprint
goos: linux
goarch: amd64
pkg: github.com/ESilva15/gobngsdk
cpu: AMD Ryzen 7 5800X3D 8-Core Processor
BenchmarkReadData-16 320931 4058 ns/op 100 B/op 2 allocs/op
PASS
ok github.com/ESilva15/gobngsdk 1.345s
# New footprint
goos: linux
goarch: amd64
pkg: github.com/ESilva15/gobngsdk
cpu: AMD Ryzen 7 5800X3D 8-Core Processor
BenchmarkReadData-16 362514 3188 ns/op 4 B/op 1 allocs/op
PASS
ok github.com/ESilva15/gobngsdk 1.194s
# Pretty good enough. I can finally go be productive instead of "procrastinating" here
```