Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion read.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ func fillBufferSingleBitAllocated(pixelData []int, d *dicomio.Reader, bo binary.
}

var currentByte byte
rawData := make([]byte, 1)
for i := 0; i < len(pixelData)/8; i++ {
rawData := make([]byte, 1)
_, err := d.Read(rawData)
if err != nil {
return err
Expand Down
25 changes: 25 additions & 0 deletions read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,31 @@ func BenchmarkReadNativeFrames(b *testing.B) {
}
}

func BenchmarkFillBufferSingleBitAllocated(b *testing.B) {
sizes := []struct {
name string
pixels int
}{
{"512x512", 512 * 512},
{"1024x1024", 1024 * 1024},
}
for _, s := range sizes {
b.Run(s.name, func(b *testing.B) {
rawBytes := make([]byte, s.pixels/8)
for i := range rawBytes {
rawBytes[i] = byte(rand.Intn(256))
}
pixelData := make([]int, s.pixels)
b.ResetTimer()
for i := 0; i < b.N; i++ {
buf := bytes.NewReader(rawBytes)
r := dicomio.NewReader(bufio.NewReader(buf), binary.LittleEndian, int64(len(rawBytes)))
_ = fillBufferSingleBitAllocated(pixelData, r, binary.LittleEndian)
}
})
}
}

func buildReadNativeFramesInput(rows, cols, numFrames, samplesPerPixel int, b *testing.B) (*Dataset, *dicomio.Reader) {
b.Helper()
dataset := Dataset{
Expand Down
Loading