Drop the write-only direction fields and the unused pattern names

This commit is contained in:
flamingcow
2026-08-04 12:26:10 -07:00
parent 21b20d0071
commit 03b7ff4954
2 changed files with 14 additions and 25 deletions
+14 -19
View File
@@ -17,19 +17,14 @@ const (
var crcTable = crc32.MakeTable(crc32.Castagnoli) var crcTable = crc32.MakeTable(crc32.Castagnoli)
type pattern struct { var patterns = []func([]byte){
name string func(b []byte) { clear(b) },
fill func([]byte) func(b []byte) {
}
var patterns = []pattern{
{"zeros", func(b []byte) { clear(b) }},
{"ones", func(b []byte) {
for i := range b { for i := range b {
b[i] = 0xff b[i] = 0xff
} }
}}, },
{"alt", func(b []byte) { func(b []byte) {
for i := range b { for i := range b {
if i%2 == 0 { if i%2 == 0 {
b[i] = 0x55 b[i] = 0x55
@@ -37,13 +32,13 @@ var patterns = []pattern{
b[i] = 0xaa b[i] = 0xaa
} }
} }
}}, },
{"incr", func(b []byte) { func(b []byte) {
for i := range b { for i := range b {
b[i] = byte(i) b[i] = byte(i)
} }
}}, },
{"prbs", func(b []byte) { func(b []byte) {
s := uint64(0x0123456789abcdef) s := uint64(0x0123456789abcdef)
for i := range b { for i := range b {
s ^= s << 13 s ^= s << 13
@@ -51,13 +46,13 @@ var patterns = []pattern{
s ^= s << 17 s ^= s << 17
b[i] = byte(s) b[i] = byte(s)
} }
}}, },
{"random", func(b []byte) { func(b []byte) {
r := rand.New(rand.NewPCG(0xc0ffee, 0x5eed)) r := rand.New(rand.NewPCG(0xc0ffee, 0x5eed))
for i := range b { for i := range b {
b[i] = byte(r.Uint32()) b[i] = byte(r.Uint32())
} }
}}, },
} }
// Every pattern is laid out at full length up front with its checksum at each // Every pattern is laid out at full length up front with its checksum at each
@@ -88,9 +83,9 @@ func newFrameSpec(dst, src [6]byte, etherType uint16, sizes []int) *frameSpec {
maxSize: maxSize, maxSize: maxSize,
maxPay: maxSize - minFrame, maxPay: maxSize - minFrame,
} }
for _, p := range patterns { for _, fill := range patterns {
ref := make([]byte, f.maxPay) ref := make([]byte, f.maxPay)
p.fill(ref) fill(ref)
crcFor := make(map[int]uint32, len(sizes)) crcFor := make(map[int]uint32, len(sizes))
for _, s := range sizes { for _, s := range sizes {
crcFor[s] = crc32.Checksum(ref[:s-minFrame], crcTable) crcFor[s] = crc32.Checksum(ref[:s-minFrame], crcTable)
-6
View File
@@ -34,10 +34,7 @@ func (e endpoint) macString() string {
} }
type direction struct { type direction struct {
label string
short string short string
tx endpoint
rx endpoint
specs []*frameSpec specs []*frameSpec
txStats []*txStats txStats []*txStats
rxStats []*rxStats rxStats []*rxStats
@@ -450,10 +447,7 @@ func (d *direction) primeCounters() {
func buildDirection(label string, tx, rx endpoint, sizes []int, cfg config) (*direction, error) { func buildDirection(label string, tx, rx endpoint, sizes []int, cfg config) (*direction, error) {
d := &direction{ d := &direction{
label: label,
short: tx.tag + "→" + rx.tag, short: tx.tag + "→" + rx.tag,
tx: tx,
rx: rx,
streams: newLossWindows(cfg.streams), streams: newLossWindows(cfg.streams),
cable: newCableStats(), cable: newCableStats(),
} }