Added TriangleData benchmarks and improvements #183
Merged
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.
Raising as draft as I haven't had time to fully test this hasn't broken things. I'll mark as ready when I've checked some examples, etcStarting to address #46 - thought it'd be too big for one go. This PR adds benchmarks for all exported methods of
pixel.TriangleData
, I've gone for the "low hanging fruit" and trimmed off a decent amount of heap allocation, and sped some of the more heavily used functions.These are the benchmarks on the code unaltered:
Benchmarks after these PR changes:
Improvements to note:
MakeTrianglesData()
for slice of 10,000 reduced op-time by ~1.5ms (~16% original time)TriangleData.Update()
for slice of 10,000 reduced op-time by ~7000ns (~86% original time)TriangleData.Copy()
for slice of 20 reduced op time by >2000ns (~36% original time).TriangleData.Copy()
for slice of 10,000 reduced op-time by ~1.4ms (~21% original time)TriangleData.Copy()
for slice of 10,000 reduced allocations per op by 20 (~9% original allocs per op)This does not resolve the issue, and does not attempt to implement the suggested new interface. Until there are benchmarks, we won't know whether speed is improving; this PR is intended as a stepping stone.