refactored for easier mainenance, add Alloc and Metrics classes

This commit is contained in:
2025-10-21 09:41:18 +02:00
parent ff3073074b
commit f1a07a1f63
9 changed files with 393 additions and 297 deletions

27
cmd/alloc.go Normal file
View File

@@ -0,0 +1,27 @@
package cmd
import "github.com/ncw/directio"
// aligned allocs used for testing
type Alloc struct {
writeBlock []byte
readBlock []byte
}
// zero the memory blocks
func (alloc *Alloc) Clean() {
for i := range alloc.writeBlock {
alloc.writeBlock[i] = 0
}
for i := range alloc.readBlock {
alloc.readBlock[i] = 0
}
}
func NewAlloc() *Alloc {
return &Alloc{
writeBlock: directio.AlignedBlock(directio.BlockSize),
readBlock: directio.AlignedBlock(directio.BlockSize),
}
}