-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Description
It would probably be better to use memory pool like this:
// devicePool reuses Device instances to reduce allocations.
var devicePool = sync.Pool{
New: func() any {
return new(Device)
},
}...and using something it like this:
device := devicePool.Get().(*Device)
device.Id = 1
device.Mac = "EF-2B-C4-F5-D6-34"
device.Firmware = "2.1.5"
renderJSON(w, device, 200)
// Optionally reset the device state
device.Id = 0
device.Mac = ""
device.Firmware = ""
// And return it to the pool.
devicePool.Put(device)Go has quite a good benchmark tools also, so using those would probably detect where the bottleneck is.
PS: For security reasons I'm not going to run anything from this branch on my development system.
Metadata
Metadata
Assignees
Labels
No labels