Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite TransformSequence<> into a struct #6382

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

smoogipoo
Copy link
Contributor

This is a WIP that I'm PRing for later self review+work and if anyone's interested in a sneak peek.

My ideal future is one where Transform and TransformSequence are both structs and transforms can be added with zero allocation overhead. We try to avoid using transforms for per-frame tasks in any case for this reason.

Take the results below with a grain of salt, because this PR has not been validated. Only the difference in allocations is notable.

Before:

|                               Method |           Mean |         Error |        StdDev |   Gen0 |   Gen1 | Allocated |
|------------------------------------- |---------------:|--------------:|--------------:|-------:|-------:|----------:|
|                    CreateSingleBlank |       4.794 ns |     0.0845 ns |     0.0791 ns | 0.0153 |      - |      96 B |
|             CreateSequenceThenRewind | 344,108.612 ns | 5,363.0188 ns | 4,187.0923 ns | 0.4883 |      - |    4688 B |
| CreateSequenceThenRewindManyChildren | 465,112.316 ns | 6,248.2433 ns | 5,217.5662 ns | 8.3008 | 0.4883 |   52780 B |
|         CreateSequenceThenClearAfter |   2,898.239 ns |    29.4509 ns |    24.5928 ns | 0.7439 |      - |    4688 B |
|                               Expiry |  14,412.256 ns |   189.9947 ns |   177.7212 ns | 0.1831 |      - |    1192 B |
|      CreateSequenceWithDefaultEasing |     581.562 ns |     3.6463 ns |     3.0449 ns | 0.1907 |      - |    1200 B |
|       ApplySequenceWithDefaultEasing |     222.065 ns |     1.3321 ns |     1.2461 ns | 0.0432 |      - |     272 B |
|        CreateSequenceWithValueEasing |     765.976 ns |     3.6702 ns |     3.0648 ns | 0.1907 |      - |    1200 B |
|         ApplySequenceWithValueEasing |     174.066 ns |     0.8849 ns |     0.8277 ns | 0.0432 |      - |     272 B |
|    CreateSequenceWithReferenceEasing |     578.842 ns |     3.5403 ns |     2.9563 ns | 0.2022 |      - |    1272 B |
|     ApplySequenceWithReferenceEasing |     178.105 ns |     0.8357 ns |     0.7817 ns | 0.0470 |      - |     296 B |

After:

|                               Method |           Mean |         Error |        StdDev |   Gen0 | Allocated |
|------------------------------------- |---------------:|--------------:|--------------:|-------:|----------:|
|                    CreateSingleBlank |       4.716 ns |     0.1398 ns |     0.1554 ns | 0.0166 |     104 B |
|             CreateSequenceThenRewind | 403,289.862 ns |   476.1260 ns |   422.0733 ns |      - |    1408 B |
| CreateSequenceThenRewindManyChildren | 511,107.716 ns | 2,364.3178 ns | 1,974.3125 ns | 3.9063 |   28699 B |
|         CreateSequenceThenClearAfter |   1,377.387 ns |    26.9680 ns |    31.0563 ns | 0.2232 |    1408 B |
|                               Expiry |  13,454.197 ns |    26.6652 ns |    24.9427 ns | 0.0610 |     392 B |
|      CreateSequenceWithDefaultEasing |     417.797 ns |     7.3259 ns |     6.8526 ns | 0.0625 |     392 B |
|       ApplySequenceWithDefaultEasing |     194.717 ns |     0.3664 ns |     0.3248 ns | 0.0203 |     128 B |
|        CreateSequenceWithValueEasing |     404.530 ns |     0.6767 ns |     0.5998 ns | 0.0625 |     392 B |
|         ApplySequenceWithValueEasing |     194.832 ns |     0.4842 ns |     0.4043 ns | 0.0203 |     128 B |
|    CreateSequenceWithReferenceEasing |     409.920 ns |     0.8955 ns |     0.8377 ns | 0.0739 |     464 B |
|     ApplySequenceWithReferenceEasing |     197.879 ns |     0.5045 ns |     0.4472 ns | 0.0241 |     152 B |

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

Successfully merging this pull request may close these issues.

1 participant