Add GetByteRange benchmark across the main IByteBuffer types by Zeejfps · Pull Request #2202 · fo-dicom/fo-dicom · GitHub
Skip to content

Add GetByteRange benchmark across the main IByteBuffer types - #2202

Open
Zeejfps wants to merge 1 commit into
fo-dicom:developmentfrom
Zeejfps:feature/bytebuffer-getbyterange-benchmark
Open

Zeejfps wants to merge 1 commit into
fo-dicom:developmentfrom
Zeejfps:feature/bytebuffer-getbyterange-benchmark

Conversation

@Zeejfps

@Zeejfps Zeejfps commented Oct 20, 2026

Copy link
Copy Markdown

Related to #2122. Adds a baseline benchmark for IByteBuffer.GetByteRange, so the upcoming Span-based buffer changes can show before/after numbers.

Checklist

  • The pull request branch is in sync with latest commit on the fo-dicom/development branch
  • I have updated API documentation (n/a: benchmark only)
  • I have included unit tests (n/a: benchmark only)
  • I have updated the change log (benchmark-only changes aren't listed)
  • I am listed in the CONTRIBUTORS file (added in Fix SwapByteBuffer.GetByteRange swapping bytes beyond the requested count #2198, still open)

Changes proposed in this pull request:

  • Add ByteBufferGetByteRangeBenchmark. It calls the byte[] GetByteRange through IByteBuffer on MemoryByteBuffer, RangeByteBuffer, CompositeByteBuffer (memory and temp-file children), EvenLengthBuffer (memory and temp-file inner buffer), EndianByteBuffer (big endian, 2-byte units) and TempFileBuffer.
  • Two read sizes over one 512x512 16-bit frame (512 KB): 64 bytes, like a single element value, and 256 KB, which crosses three of the four composite parts.
  • MemoryByteBuffer is the baseline; [MemoryDiagnoser] is on.

Results on development

.NET 10, AMD Ryzen 9 5900X.

Method 64 B 256 KB
Memory 4.0 ns 17.5 µs
Range 4.8 ns 17.7 µs
CompositeOfMemory 10.3 ns 4.6 µs
CompositeOfTempFiles 165 µs, 4.4 KB 641 µs, 936 B
EvenLength 5.1 ns 4.6 µs
EvenLengthOfTempFile 226 µs, 513 KB 230 µs, 513 KB
EndianSwapped 15.2 ns 58 µs
TempFile 162 µs, 4.4 KB 169 µs, 240 B

EvenLengthOfTempFile allocates the whole 512 KB inner buffer even for a 64-byte read.

Measures the byte[] GetByteRange on memory, range, composite (memory and temp-file children), even-length (memory and temp-file inner buffer), endian-swapped and temp-file buffers, for a 64-byte read and a 256 KB read.

Related to fo-dicom#2122
@sonarqubecloud

sonarqubecloud Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Comment thread Tests/FO-DICOM.Benchmark/ByteBufferGetByteRangeBenchmark.cs Dismissed
@Zeejfps

Zeejfps commented Oct 25, 2026

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants