-
-
Notifications
You must be signed in to change notification settings - Fork 17
Speed up TemplateDataEncoder
significantly.
#50
Conversation
Results: - Before the optimizations, each invocation inside `measure` takes about 4s on my Core i7-6700k. - After conforming `Data` to `TemplateDataRepresentable`, each invocation inside `measure` takes about 0.2s. - After rewriting `TemplateDataEncoder`, the runtime halves again to 0.1s. (`NestedData` is fairly inefficient, especially for "deeper" hierarchies.)
…ten`. This further halves the runtime in vapor/template-kit#50 from 0.1s to 50ms.
…ten`. This further halves the runtime in vapor/template-kit#50 from 0.1s to 50ms.
…ten (#199) * Significantly improve the performance of `Collection<FutureType>.flatten`. This further halves the runtime in vapor/template-kit#50 from 0.1s to 50ms. * Add a benchmark for `flatten`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. It looks like a similar method to what I've been using for Vapor 4's encoders. See this one for example: https://github.com/vapor/leaf/pull/139/files#diff-a1f7fd8772e8db228f62e4a0b303ee06R1
Looks like there is a CI failure:
|
Thanks for spotting that! I've updated the tests now; hopefully this will be fixed now. |
Weird; on Mac the |
Added a manual implementation of |
78e4bdf
to
d3755cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks @MrMage !
Hey @MrMage, you just merged a pull request, have a coin! You now have 26 coins. |
Results:
measure
takes about 4s on my Core i7-6700k.Data
toTemplateDataRepresentable
, each invocation insidemeasure
takes about 0.2s.TemplateDataEncoder
, the runtime halves again to 0.1s. (NestedData
is fairly inefficient, especially for "deeper" hierarchies.)Screenshot (including the improvements from vapor/core#199):