Repository navigation
docs(readme): fix throughput example and entropy description - #89
Merged
Merged
Conversation
CalculateThroughput divides the array length by the duration it is given, so the MeasurePerformance examples must pass averageTime, not totalTime. CalculateEntropy measures the byte-value distribution and ignores order; describe it that way.
The XML docs called entropy a measure of randomness and 0.0 'perfectly ordered'. CalculateEntropy only counts how often each byte value occurs and ignores their order. Comment-only change.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the documentation-only corrections to throughput examples and entropy explanations.
No open issues 🎉
What changed in this PR
This documentation-only follow-up to #88 corrects throughput examples and clarifies what byte-distribution entropy measures. No library behavior or public APIs change.
Changes:
- Use average iteration time rather than total elapsed time when calculating throughput.
- Describe entropy in terms of byte-value frequencies, independent of byte order.
- Revise entropy use cases to avoid presenting it as a randomness test.
| File | Description |
|---|---|
| README.md | Corrects the throughput example and entropy explanation. |
| Plugin.ByteArrays.Docs/ReadOnlySpanUtilities.md | Clarifies entropy’s meaning, range, and use cases. |
| Plugin.ByteArrays.Docs/ByteArrayUtilities.md | Clarifies entropy and fixes throughput timing in the analysis example. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #88, from the review comments left on it. Two statements in the docs were wrong.
MeasurePerformancetimes all iterations (totalTime), whileCalculateThroughputdividesdata.Lengthby the duration it is given, so the duration must be that of a single run. The README passedtotalTime(1000 iterations), which understated throughput by a factor of 1000. It now passesaverageTime. The same mistake was in the analysis-pipeline example inDocs/ByteArrayUtilities.md(100 iterations); fixed there too. Every otherCalculateThroughputcall in the docs and in.github/copilot-instructions.mdalready passes a single-run time.CalculateEntropyis the Shannon entropy of the byte-value distribution. It counts occurrences and ignores order, so the sequence0..255and any permutation of it both give 8.0, and 0.0 means a single distinct value. The README comment described it as "ordered … random", andDocs/ReadOnlySpanUtilities.mdsaid the same ("randomness", "perfectly ordered", and use cases such as testing random number generators). Both now describe the distribution, and the use cases no longer suggest a randomness test.I checked the claims by running them in a scratch project: entropy of
0..255and of a shuffled copy is 8, of{5,5,5,5}is 0; with 200 iterations the throughput computed fromtotalTimeis 1/200 of the one computed fromaverageTime, and the latter matches an independent single-run measurement. The README andDocs/index.mdC# snippets still compile against the library.Why
A reader copying the README example got a throughput figure that was off by the iteration count, and the entropy wording promised more than the function measures.
Not changed here: the XML doc comments on
CalculateEntropyinReadOnlySpanUtilities.csandByteArrayUtilities.csuse similar "randomness" wording. They are source comments, so I left them for a separate change.Change Type
Affected Areas
ByteArrayExtensionsReadOnlySpanExtensions/ReadOnlyMemoryExtensionsByteArrayBuilderBehavior And Compatibility
Tests
Documentation
Checklist
type(scope): subject)