Skip to content

Commit

Permalink
Refactor symbolsPerBlock, should have no effect though. Add decoder b…
Browse files Browse the repository at this point in the history
…enchmarks.
  • Loading branch information
bemasher committed Sep 30, 2016
1 parent 1da5fcd commit 57926fc
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion decode/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func NewDecoder(cfg PacketConfig, decimation int) (d Decoder) {
// memory local.
d.slices = make([][]byte, d.DecCfg.SymbolLength)

symbolsPerBlock := d.DecCfg.BlockSize/d.DecCfg.SymbolLength + d.DecCfg.PreambleSymbols
symbolsPerBlock := (d.DecCfg.BlockSize + d.DecCfg.PreambleLength) / d.DecCfg.SymbolLength
for symbolOffset := range d.slices {
d.slices[symbolOffset] = make([]byte, symbolsPerBlock)
}
Expand Down
57 changes: 57 additions & 0 deletions decode/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,63 @@ func NewPacketConfig(chipLength int) (cfg PacketConfig) {
return
}

func BenchmarkMagLUT(b *testing.B) {
d := NewDecoder(NewPacketConfig(72), 1)

input := make([]byte, d.DecCfg.BlockSize2)

b.SetBytes(int64(d.DecCfg.BlockSize))
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
d.demod.Execute(input, d.Signal[d.DecCfg.SymbolLength:])
}
}

func BenchmarkFilter(b *testing.B) {
d := NewDecoder(NewPacketConfig(72), 1)

b.SetBytes(int64(d.DecCfg.BlockSize))
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
d.Filter(d.Signal, d.Filtered)
}
}

func BenchmarkQuantize(b *testing.B) {
d := NewDecoder(NewPacketConfig(72), 1)

b.SetBytes(int64(d.DecCfg.BlockSize))
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
Quantize(d.Filtered[d.DecCfg.SymbolLength:], d.Quantized[d.DecCfg.PacketLength:])
}
}

func BenchmarkTranspose(b *testing.B) {
d := NewDecoder(NewPacketConfig(72), 1)

b.SetBytes(int64(d.DecCfg.BlockSize))
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
d.Transpose(d.Quantized)
}
}

func BenchmarkSearch(b *testing.B) {
d := NewDecoder(NewPacketConfig(72), 1)

b.SetBytes(int64(d.DecCfg.BlockSize))
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
_ = d.Search()
}
}

func BenchmarkDecode(b *testing.B) {
d := NewDecoder(NewPacketConfig(72), 1)

Expand Down

0 comments on commit 57926fc

Please sign in to comment.