Skip to content

Faster to replace the entire component than to update fields - expected? #49

Answered by Stovoy
Stovoy asked this question in Q&A
Discussion options

You must be logged in to vote

Benchmark: https://gist.github.com/Stovoy/04229a08b1caf699ecec69597426344f

Results:

|           Method |     Mean |   Error |  StdDev |   Median |
|----------------- |---------:|--------:|--------:|---------:|
| NewWithIncrement | 199.9 us | 3.34 us | 8.31 us | 197.0 us |
|  NewWithAddition | 194.7 us | 2.82 us | 2.35 us | 194.2 us |
|    UpdateInPlace | 193.0 us | 1.09 us | 0.85 us | 193.1 us |

My current guess is that this is some runtime-optimization coming from the JIT compiler optimizing these loops over spans.

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Stovoy
Comment options

Comment options

You must be logged in to vote
1 reply
@genaray
Comment options

Answer selected by genaray
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants